Class ComputerGraph

  • All Implemented Interfaces:
    AutoCloseable, Graph, Host

    public final class ComputerGraph
    extends Object
    implements Graph
    Author:
    Marko A. Rodriguez (http://markorodriguez.com)
    • Method Detail

      • addVertex

        public Vertex addVertex​(Object... keyValues)
        Description copied from interface: Graph
        Add a Vertex to 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 are String property keys and the even numbered arguments are the related property values.
        Specified by:
        addVertex in interface Graph
        Parameters:
        keyValues - The key/value pairs to turn into vertex properties
        Returns:
        The newly created vertex
      • compute

        public <C extends GraphComputer> C compute​(Class<C> graphComputerClass)
                                            throws IllegalArgumentException
        Description copied from interface: Graph
        Declare the GraphComputer to use for OLAP operations on the graph. If the graph does not support graph computer then an UnsupportedOperationException is thrown.
        Specified by:
        compute in interface Graph
        Parameters:
        graphComputerClass - The graph computer class to use.
        Returns:
        A graph computer for processing this graph
        Throws:
        IllegalArgumentException - if the provided GraphComputer class is not supported.
      • vertices

        public Iterator<Vertex> vertices​(Object... vertexIds)
        Description copied from interface: Graph
        Get the Vertex objects in this graph with the provided vertex ids or Vertex objects 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 the Graph.Features around id support, multiple arguments might be applicable here.

        If the graph return true for Graph.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")

        If the graph return true for Graph.Features.ElementFeatures.supportsCustomIds() ()} then it should support filters as with:

        • g.vertices(v)
        • g.vertices(v.id())
        • g.vertices(v.id().toString())

        If the graph return true for Graph.Features.ElementFeatures.supportsAnyIds() ()} then it should support filters as with:

        • g.vertices(v)
        • g.vertices(v.id())

          If the graph return true for Graph.Features.ElementFeatures.supportsStringIds() ()} then it should support filters as with:

        • g.vertices(v)
        • g.vertices(v.id().toString())
        • g.vertices("id")

        If the graph return true for Graph.Features.ElementFeatures.supportsStringIds() ()} then it should support filters as with:

        • g.vertices(v)
        • g.vertices(v.id().toString())
        • g.vertices("id")
        Specified by:
        vertices in interface Graph
        Parameters:
        vertexIds - the ids of the vertices to get
        Returns:
        an Iterator of vertices that match the provided vertex ids
      • edges

        public Iterator<Edge> edges​(Object... edgeIds)
        Description copied from interface: Graph
        Get the Edge objects in this graph with the provided edge ids or Edge objects. 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 the Graph.Features around id support, multiple arguments might be applicable here.

        If the graph return true for Graph.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")

        If the graph return true for Graph.Features.ElementFeatures.supportsCustomIds() ()} then it should support filters as with:

        • g.edges(e)
        • g.edges(e.id())
        • g.edges(e.id().toString())

        If the graph return true for Graph.Features.ElementFeatures.supportsAnyIds() ()} then it should support filters as with:

        • g.edges(e)
        • g.edges(e.id())

        If the graph return true for Graph.Features.ElementFeatures.supportsStringIds() ()} then it should support filters as with:

        • g.edges(e)
        • g.edges(e.id().toString())
        • g.edges("id")
        Specified by:
        edges in interface Graph
        Parameters:
        edgeIds - the ids of the edges to get
        Returns:
        an Iterator of edges that match the provided edge ids
      • tx

        public Transaction tx()
        Description copied from interface: Graph
        Configure and control the transactions for those graphs that support this feature.
        Specified by:
        tx in interface Graph
      • variables

        public Graph.Variables variables()
        Description copied from interface: Graph
        A collection of global Graph.Variables associated with the graph. Variables are used for storing metadata about the graph.
        Specified by:
        variables in interface Graph
        Returns:
        The variables associated with this graph
      • configuration

        public org.apache.commons.configuration2.Configuration configuration()
        Description copied from interface: Graph
        Get the Configuration associated with the construction of this graph. Whatever configuration was passed to GraphFactory.open(Configuration) is what should be returned by this method.
        Specified by:
        configuration in interface Graph
        Returns:
        the configuration used during graph construction.
      • close

        public void close()
                   throws Exception
        Description copied from interface: Graph
        Closing a Graph is 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 calls close() with other threads that are accessing open transactions. In other words, be sure that all work performed on the Graph instance 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:
        close in interface AutoCloseable
        Specified by:
        close in interface Graph
        Throws:
        Exception