Class TinkerGraph
- java.lang.Object
- 
- org.apache.tinkerpop.gremlin.tinkergraph.structure.AbstractTinkerGraph
- 
- org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
 
 
- 
- All Implemented Interfaces:
- AutoCloseable,- Graph,- Host
 
 public class TinkerGraph extends AbstractTinkerGraph An in-memory (with optional persistence on calls toAbstractTinkerGraph.close()), reference implementation of the property graph interfaces provided by TinkerPop.- Author:
- Marko A. Rodriguez (http://markorodriguez.com), Stephen Mallette (http://stephen.genoprime.com)
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description classTinkerGraph.TinkerGraphFeaturesclassTinkerGraph.TinkerGraphGraphFeatures- 
Nested classes/interfaces inherited from class org.apache.tinkerpop.gremlin.tinkergraph.structure.AbstractTinkerGraphAbstractTinkerGraph.DefaultIdManager, AbstractTinkerGraph.IdManager<T>, AbstractTinkerGraph.TinkerGraphEdgeFeatures, AbstractTinkerGraph.TinkerGraphVertexFeatures, AbstractTinkerGraph.TinkerGraphVertexPropertyFeatures
 - 
Nested classes/interfaces inherited from interface org.apache.tinkerpop.gremlin.structure.GraphGraph.Exceptions, Graph.Features, Graph.Hidden, Graph.OptIn, Graph.OptIns, Graph.OptOut, Graph.OptOuts, Graph.Variables
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected Map<Object,Edge>edgesprotected Map<Object,Vertex>vertices- 
Fields inherited from class org.apache.tinkerpop.gremlin.tinkergraph.structure.AbstractTinkerGraphallowNullPropertyValues, configuration, currentId, defaultVertexPropertyCardinality, edgeIdManager, edgeIndex, graphComputerView, graphFormat, graphLocation, GREMLIN_TINKERGRAPH_ALLOW_NULL_PROPERTY_VALUES, GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER, GREMLIN_TINKERGRAPH_GRAPH_FORMAT, GREMLIN_TINKERGRAPH_GRAPH_LOCATION, GREMLIN_TINKERGRAPH_SERVICE, GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER, GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER, serviceRegistry, variables, vertexIdManager, vertexIndex, vertexPropertyIdManager
 
- 
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description EdgeaddEdge(TinkerVertex outVertex, TinkerVertex inVertex, String label, Object... keyValues)protected voidaddInEdge(TinkerVertex vertex, String label, Edge edge)protected voidaddOutEdge(TinkerVertex vertex, String label, Edge edge)VertexaddVertex(Object... keyValues)Add aVertexto the graph given an optional series of key/value pairs.voidclear()Clear internal graph data<E extends Element>
 voidcreateIndex(String key, Class<E> elementClass)<E extends Element>
 voiddropIndex(String key, Class<E> elementClass)Edgeedge(Object edgeId)ReturnEdgeby id.Iterator<Edge>edges(Object... edgeIds)Graph.Featuresfeatures()Return TinkerGraph feature set.intgetEdgesCount()Graph-specific implementation for number of vertices.TinkerServiceRegistrygetServiceRegistry()Get theServiceRegistryassociated with the graph.intgetVerticesCount()Graph-specific implementation for number of vertices.booleanhasEdge(Object id)booleanhasVertex(Object id)static TinkerGraphopen()Open a newTinkerGraphinstance.static TinkerGraphopen(org.apache.commons.configuration2.Configuration configuration)Open a newTinkerGraphinstance.voidremoveEdge(Object edgeId)voidremoveVertex(Object vertexId)Transactiontx()Configure and control the transactions for those graphs that support this feature.Vertexvertex(Object vertexId)ReturnVertexby id.Iterator<Vertex>vertices(Object... vertexIds)- 
Methods inherited from class org.apache.tinkerpop.gremlin.tinkergraph.structure.AbstractTinkerGraphclose, compute, compute, configuration, createTinkerEdge, createTinkerEdge, createTinkerVertex, createTinkerVertex, getIndexedKeys, instantiate, io, loadGraph, saveGraph, selectIdManager, toString, touch, touch, variables
 
- 
 
- 
- 
- 
Method Detail- 
openpublic static TinkerGraph open() Open a newTinkerGraphinstance. Reference Implementation Help: If aGraphimplementation does not require aConfiguration(or perhaps has a default configuration) it can choose to implement a zero argumentopen()method. This is an optional constructor method for TinkerGraph. It is not enforced by the Gremlin Test Suite.
 - 
openpublic static TinkerGraph open(org.apache.commons.configuration2.Configuration configuration) Open a newTinkerGraphinstance. Reference Implementation Help: This method is the one use by theGraphFactoryto instantiateGraphinstances. This method must be overridden for the Structure Test Suite to pass. Implementers have latitude in terms of how exceptions are handled within this method. Such exceptions will be considered implementation specific by the test suite as all test generate graph instances by way ofGraphFactory. As such, the exceptions get generalized behind that facade and sinceGraphFactoryis the preferred method to opening graphs it will be consistent at that level.- Parameters:
- configuration- the configuration for the instance
- Returns:
- a newly opened Graph
 
 - 
addVertexpublic Vertex addVertex(Object... keyValues) Description copied from class:AbstractTinkerGraphAdd 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.- Specified by:
- addVertexin interface- Graph
- Specified by:
- addVertexin class- AbstractTinkerGraph
- Parameters:
- keyValues- The key/value pairs to turn into vertex properties
- Returns:
- The newly created vertex
 
 - 
removeVertexpublic void removeVertex(Object vertexId) Description copied from class:AbstractTinkerGraph- Specified by:
- removeVertexin class- AbstractTinkerGraph
 
 - 
addEdgepublic Edge addEdge(TinkerVertex outVertex, TinkerVertex inVertex, String label, Object... keyValues) Description copied from class:AbstractTinkerGraph- Specified by:
- addEdgein class- AbstractTinkerGraph
 
 - 
removeEdgepublic void removeEdge(Object edgeId) Description copied from class:AbstractTinkerGraph- Specified by:
- removeEdgein class- AbstractTinkerGraph
 
 - 
clearpublic void clear() Description copied from class:AbstractTinkerGraphClear internal graph data- Overrides:
- clearin class- AbstractTinkerGraph
 
 - 
txpublic Transaction tx() Description copied from class:AbstractTinkerGraphConfigure and control the transactions for those graphs that support this feature.- Specified by:
- txin interface- Graph
- Specified by:
- txin class- AbstractTinkerGraph
 
 - 
getVerticesCountpublic int getVerticesCount() Description copied from class:AbstractTinkerGraphGraph-specific implementation for number of vertices.- Specified by:
- getVerticesCountin class- AbstractTinkerGraph
- Returns:
- count of vertices in Graph.
 
 - 
hasVertexpublic boolean hasVertex(Object id) Description copied from class:AbstractTinkerGraph- Specified by:
- hasVertexin class- AbstractTinkerGraph
 
 - 
getEdgesCountpublic int getEdgesCount() Description copied from class:AbstractTinkerGraphGraph-specific implementation for number of vertices.- Specified by:
- getEdgesCountin class- AbstractTinkerGraph
- Returns:
- count of vertices in Graph.
 
 - 
hasEdgepublic boolean hasEdge(Object id) Description copied from class:AbstractTinkerGraph- Specified by:
- hasEdgein class- AbstractTinkerGraph
 
 - 
getServiceRegistrypublic TinkerServiceRegistry getServiceRegistry() Description copied from interface:GraphGet theServiceRegistryassociated with the graph. Used byCallStepto invoke service calls.- Returns:
- The registry of callable services
 
 - 
vertexpublic Vertex vertex(Object vertexId) Description copied from class:AbstractTinkerGraphReturnVertexby id. Does not create an iterator, so is the preferred method when only 1 element needs to be returned.- Specified by:
- vertexin class- AbstractTinkerGraph
- Returns:
- Vertex
 
 - 
verticespublic Iterator<Vertex> vertices(Object... vertexIds) Description copied from class:AbstractTinkerGraphGet 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")
 - Specified by:
- verticesin interface- Graph
- Specified by:
- verticesin class- AbstractTinkerGraph
- Parameters:
- vertexIds- the ids of the vertices to get
- Returns:
- an Iteratorof vertices that match the provided vertex ids
 
 - 
edgespublic Iterator<Edge> edges(Object... edgeIds) Description copied from class:AbstractTinkerGraphGet 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")
 - Specified by:
- edgesin interface- Graph
- Specified by:
- edgesin class- AbstractTinkerGraph
- Parameters:
- edgeIds- the ids of the edges to get
- Returns:
- an Iteratorof edges that match the provided edge ids
 
 - 
edgepublic Edge edge(Object edgeId) Description copied from class:AbstractTinkerGraphReturnEdgeby id. Does not create an iterator, so is the preferred method when only 1 element needs to be returned.- Specified by:
- edgein class- AbstractTinkerGraph
- Returns:
- Edge
 
 - 
addOutEdgeprotected void addOutEdge(TinkerVertex vertex, String label, Edge edge) - Specified by:
- addOutEdgein class- AbstractTinkerGraph
 
 - 
addInEdgeprotected void addInEdge(TinkerVertex vertex, String label, Edge edge) - Specified by:
- addInEdgein class- AbstractTinkerGraph
 
 - 
featurespublic Graph.Features features() Return TinkerGraph feature set. Reference Implementation Help: Implementers only need to implement features for which there are negative or instance configured features. By default, allGraph.Featuresreturn true.
 - 
createIndexpublic <E extends Element> void createIndex(String key, Class<E> elementClass) Create an index for said element class (VertexorEdge) and said property key. Whenever an element has the specified key mutated, the index is updated. When the index is created, all existing elements are indexed to ensure that they are captured by the index.- Type Parameters:
- E- The type of the element class
- Parameters:
- key- the property key to index
- elementClass- the element class to index
 
 
- 
 
-