Interface Graph
- All Superinterfaces:
AutoCloseable,org.apache.tinkerpop.gremlin.structure.util.Host
Graph is a container object for a collection of Vertex, Edge, VertexProperty,
and Property objects.- Author:
- Marko A. Rodriguez (http://markorodriguez.com), Stephen Mallette (http://stephen.genoprime.com), Pieter Martin
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classCommon exceptions to use with a graph.static interfaceAn interface that represents the capabilities of aGraphimplementation.static classThis should only be used by providers to create keys, labels, etc.static interfaceProvides access to property index lookups for the graph.static @interfaceDefines the test suite that the implementer has decided to support and represents publicly as "passing".static @interfaceHolds a collection ofGraph.OptInenabling multipleGraph.OptInto be applied to a single suite.static @interfaceDefines a test in the suite that the implementer does not want to run.static @interfaceHolds a collection ofGraph.OptOutenabling multipleGraph.OptOutto be applied to a single suite.static interfaceGraph variables are a set of key/value pairs associated with the graph. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionAdd aVertexto the graph given an optional series of key/value pairs.default VertexAdd aVertexto the graph with provided vertex label.voidclose()Closing aGraphis equivalent to "shutdown" and implies that no further operations can be executed on the instance.compute()Generate aGraphComputerusing the default engine of the underlying graph system.<C extends GraphComputer>
CDeclare theGraphComputerto use for OLAP operations on the graph.org.apache.commons.configuration2.ConfigurationGet theConfigurationassociated with the construction of this graph.default longcountEdgesByLabel(String label) Returns the number of edges with the given label, orLong.MAX_VALUEif unknown.default longcountVerticesByLabel(String label) Returns the number of vertices with the given label, orLong.MAX_VALUEif unknown.default Graph.Featuresfeatures()Gets theGraph.Featuresexposed by the underlyingGraphimplementation.default org.apache.tinkerpop.gremlin.structure.service.ServiceRegistryGet theServiceRegistryassociated with the graph.default Graph.Indexindex()Returns theGraph.Indexaccessor for this graph.default <I extends Io>
Iio(Io.Builder<I> builder) Deprecated.default GraphTraversalSourceGenerate a reusableGraphTraversalSourceinstance.default <C extends TraversalSource>
CGenerate aTraversalSourceusing the specifiedTraversalSourceclass.tx()Configure and control the transactions for those graphs that support this feature.default <Tx extends Transaction>
TxConfigure and control the transactions for those graphs that support this feature.A collection of globalGraph.Variablesassociated with the graph.
-
Field Details
-
GRAPH
Configuration key used byGraphFactory} to determine which graph to instantiate.- See Also:
-
-
Method Details
-
addVertex
Add aVertexto the graph given an optional series of key/value pairs. These key/values must be provided in an even number where the odd numbered arguments areStringproperty keys and the even numbered arguments are the related property values.- Parameters:
keyValues- The key/value pairs to turn into vertex properties- Returns:
- The newly created vertex
-
addVertex
Add aVertexto the graph with provided vertex label.- Parameters:
label- the label of the vertex- Returns:
- The newly created labeled vertex
-
compute
Declare theGraphComputerto use for OLAP operations on the graph. If the graph does not support graph computer then anUnsupportedOperationExceptionis thrown.- Parameters:
graphComputerClass- The graph computer class to use.- Returns:
- A graph computer for processing this graph
- Throws:
IllegalArgumentException- if the providedGraphComputerclass is not supported.
-
compute
Generate aGraphComputerusing the default engine of the underlying graph system. This is a shorthand method for the more involved method that usescompute(Class).- Returns:
- A default graph computer
- Throws:
IllegalArgumentException- if there is no default graph computer
-
traversal
Generate aTraversalSourceusing the specifiedTraversalSourceclass. The reusableTraversalSourceprovides methods for spawningTraversalinstances.- Type Parameters:
C- The traversal source class- Parameters:
traversalSourceClass- The traversal source class
-
traversal
Generate a reusableGraphTraversalSourceinstance. TheGraphTraversalSourceprovides methods for creatingGraphTraversalinstances.- Returns:
- A graph traversal source
-
vertices
Get theVertexobjects in this graph with the provided vertex ids orVertexobjects themselves. If no ids are provided, get all vertices. Note that a vertex identifier does not need to correspond to the actual id used in the graph. It needs to be a bit more flexible than that in that given theGraph.Featuresaround id support, multiple arguments might be applicable here. If the graph returntrueforGraph.Features.ElementFeatures.supportsNumericIds()then it should support filters as with:- g.vertices(v)
- g.vertices(v.id())
- g.vertices(1)
- g.vertices(1L)
- g.vertices(1.0d)
- g.vertices(1.0f)
- g.vertices("1")
trueforGraph.Features.ElementFeatures.supportsCustomIds()()} then it should support filters as with:- g.vertices(v)
- g.vertices(v.id())
- g.vertices(v.id().toString())
trueforGraph.Features.ElementFeatures.supportsAnyIds()()} then it should support filters as with:- g.vertices(v)
- g.vertices(v.id())
trueforGraph.Features.ElementFeatures.supportsStringIds()()} then it should support filters as with:- g.vertices(v)
- g.vertices(v.id().toString())
- g.vertices("id")
trueforGraph.Features.ElementFeatures.supportsStringIds()()} then it should support filters as with:- g.vertices(v)
- g.vertices(v.id().toString())
- g.vertices("id")
- Parameters:
vertexIds- the ids of the vertices to get- Returns:
- an
Iteratorof vertices that match the provided vertex ids
-
edges
Get theEdgeobjects in this graph with the provided edge ids orEdgeobjects. If no ids are provided, get all edges. Note that an edge identifier does not need to correspond to the actual id used in the graph. It needs to be a bit more flexible than that in that given theGraph.Featuresaround id support, multiple arguments might be applicable here. If the graph returntrueforGraph.Features.ElementFeatures.supportsNumericIds()then it should support filters as with:- g.edges(e)
- g.edges(e.id())
- g.edges(1)
- g.edges(1L)
- g.edges(1.0d)
- g.edges(1.0f)
- g.edges("1")
trueforGraph.Features.ElementFeatures.supportsCustomIds()()} then it should support filters as with:- g.edges(e)
- g.edges(e.id())
- g.edges(e.id().toString())
trueforGraph.Features.ElementFeatures.supportsAnyIds()()} then it should support filters as with:- g.edges(e)
- g.edges(e.id())
trueforGraph.Features.ElementFeatures.supportsStringIds()()} then it should support filters as with:- g.edges(e)
- g.edges(e.id().toString())
- g.edges("id")
- Parameters:
edgeIds- the ids of the edges to get- Returns:
- an
Iteratorof edges that match the provided edge ids
-
tx
Transaction tx()Configure and control the transactions for those graphs that support this feature. -
tx
Configure and control the transactions for those graphs that support this feature. Graphs that support multiple transaction models can use this method expose different sorts ofTransactionimplementations. -
close
Closing aGraphis equivalent to "shutdown" and implies that no further operations can be executed on the instance. Users should consult the documentation of the underlying graph database implementation for what this "shutdown" will mean in general and, if supported, how open transactions are handled. It will typically be the end user's responsibility to synchronize the thread that callsclose()with other threads that are accessing open transactions. In other words, be sure that all work performed on theGraphinstance is complete prior to calling this method. TinkerPop does not enforce any particular semantics with respect to "shutdown". It is up to the graph provider to decide what this method will do.- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
io
Deprecated.As of release 3.4.0, partially replaced byGraphTraversalSource.io(String). NoticeGraphTraversalSource.io(String)doesn't support read operation fromjava.io.InputStreamor write operation tojava.io.OutputStream. Thus for readers or writers which need this functionality are safe to use this deprecated method. There is no intention to remove this method unless all the functionality is replaced by the `io` step ofGraphTraversalSource.Construct a particularIoimplementation for reading and writing theGraphand other data. End-users will "select" theIoimplementation that they want to use by supplying theIo.Builderthat constructs it. In this way,Graphvendors can supply theirIoRegistryto that builder thus allowing for custom serializers to be auto-configured into theIoinstance. Registering custom serializers is particularly useful for those graphs that have complex types forElementidentifiers. For those graphs that do not need to register any custom serializers, the default implementation should suffice. If the default is overridden, take care to register the current graph via theIo.Builder.graph(Graph)method. -
variables
Graph.Variables variables()A collection of globalGraph.Variablesassociated with the graph. Variables are used for storing metadata about the graph.- Returns:
- The variables associated with this graph
-
countVerticesByLabel
Returns the number of vertices with the given label, orLong.MAX_VALUEif unknown. Anulllabel returns the total vertex count regardless of label.The default implementation returns
Long.MAX_VALUE. Graph implementations that maintain label cardinality counts should override this method to enable the GQL planner to select an optimal seed variable and order extension steps by label density. Approximate values are sufficient; exact counts are not required. -
countEdgesByLabel
Returns the number of edges with the given label, orLong.MAX_VALUEif unknown. Anulllabel returns the total edge count regardless of label.The default implementation returns
Long.MAX_VALUE. Graph implementations that maintain edge label cardinality counts should override this method to enable the GQL planner to order extension steps by edge-label density so that rarer labels prune the DFS search space sooner. -
index
Returns theGraph.Indexaccessor for this graph. The default implementation returnsGraph.Index.EMPTY, whose methods return conservative values indicating that no property index is available.Graph implementations that maintain property indexes should override this method and return an
Graph.Indexbacked by their index structures. The GQL executor uses theGraph.Indexto replace full vertex scans with targeted lookups for selective predicates. -
configuration
org.apache.commons.configuration2.Configuration configuration()Get theConfigurationassociated with the construction of this graph. Whatever configuration was passed toGraphFactory.open(Configuration)is what should be returned by this method.- Returns:
- the configuration used during graph construction.
-
getServiceRegistry
default org.apache.tinkerpop.gremlin.structure.service.ServiceRegistry getServiceRegistry()Get theServiceRegistryassociated with the graph. Used byCallStepto invoke service calls.- Returns:
- The registry of callable services
-
features
Gets theGraph.Featuresexposed by the underlyingGraphimplementation.
-
GraphTraversalSource.io(String).