Class QueryGraph

java.lang.Object
org.apache.tinkerpop.gremlin.gql.QueryGraph

public final class QueryGraph extends Object
The logical graph structure produced by parsing a GQL MATCH clause. A QueryGraph holds the complete set of QueryVertex and QueryEdge objects that represent the pattern to match, preserving the variable-identity relationships across multiple comma-separated path patterns.

Variable identity is enforced: if the same variable name appears in multiple patterns, the corresponding QueryVertex instances are shared (reference-equal) in the resulting graph.

Use parse(String) to construct a QueryGraph from a GQL MATCH string.

  • Method Details

    • getNodes

      public List<QueryVertex> getNodes()
      Returns the ordered list of all nodes in this pattern graph.
    • getEdges

      public List<QueryEdge> getEdges()
      Returns the ordered list of all edges in this pattern graph.
    • parse

      public static QueryGraph parse(String gqlMatchString)
      Parses a GQL MATCH string and returns the corresponding QueryGraph.

      The input must begin with the MATCH keyword followed by one or more comma-separated path patterns. Example:

         MATCH (a:Person)-[:KNOWS]->(b:Person)
         MATCH (a:Person)-[:KNOWS]->(b:Person), (b)-[:WORKS_AT]->(c:Company)
       
      Parameters:
      gqlMatchString - a GQL MATCH expression
      Returns:
      the constructed QueryGraph
      Throws:
      IllegalArgumentException - if the string cannot be parsed
    • toString

      public String toString()
      Overrides:
      toString in class Object