← Back to the previous page

Pattern Workload

Queries that find patterns in the graph.

Queries

Select a query type below to view its template and description.

T3.1 Triangle Detection

Generic Intent: Find triangles involving a given node.

This query identifies triangle relationships involving a target node. It measures pattern matching engine performance on join optimization over graph topology.

Template:

Note: This query can be slightly modified by adding arrows to the edge relationships to find different patterns within a triangle.

gql
MATCH (a:<NodeLabel> {<idProp>: $startId})-[:<EdgeType>]-(b:<NodeLabel>),
      (b)-[:<EdgeType>]-(c:<NodeLabel>),
      (c)-[:<EdgeType>]-(a)
WHERE a <> b AND b <> c AND a <> c
RETURN DISTINCT a, b, c
LIMIT $limit;

Parameters:

  • Clustering density: high-clustering vs low-clustering regions
  • Direction: outgoing / incoming / undirected (cyclic directed vs undirected)
  • Start node (degree): low / medium / high (measures fanout scaling)
  • Limit size: small / large / no limit
  • Duplicate elimination: distinct vs non-distinct counting

T3.2 Square Detection

Generic Intent: Find squares (4-node cycles) involving a given node.

This query identifies 4-node cyclic relationships (squares) involving a target node. It measures pattern matching engine performance on multi-way joins and path cycle detection.

Template:

Note: This query can be slightly modified by adding arrows to the edge relationships to find different patterns within a square.

gql
MATCH (a:<NodeLabel> {<idProp>: $startId})-[:<EdgeType>]-(b:<NodeLabel>),
      (b)-[:<EdgeType>]-(c:<NodeLabel>),
      (c)-[:<EdgeType>]-(d:<NodeLabel>),
      (d)-[:<EdgeType>]-(a)
WHERE a <> b AND a <> c AND a <> d AND b <> c AND b <> d AND c <> d
RETURN DISTINCT a, b, c, d
LIMIT $limit;

Parameters:

  • Clustering density: high-clustering vs low-clustering regions
  • Direction: outgoing / incoming / undirected (cyclic directed vs undirected)
  • Start node (degree): low / medium / high (measures fanout scaling)
  • Limit size: small / large / no limit
  • Duplicate elimination: distinct vs non-distinct counting

T3.3 Star Pattern Query

Generic Intent: Find center hub nodes with many neighbors satisfying specific conditions.

This query identifies center "hub" nodes connected to many neighboring nodes. It tests global vs local aggregations, hash-join scaling, and sort/top-K capabilities under skewed degree distributions.

Undirected Edge GQL Template:

gql
MATCH (center:<NodeLabel>)-[:<EdgeType>]-(n:<NodeLabel>)
WITH center, COUNT(DISTINCT n) AS degree
WHERE degree >= $minDegree
RETURN center, degree
ORDER BY degree DESC
LIMIT $limit;

Outgoing Edge GQL Template:

gql
MATCH (center:<NodeLabel>)-[:<EdgeType>]->(n:<NodeLabel>)
WITH center, COUNT(DISTINCT n) AS degree
WHERE degree >= $minDegree
RETURN center, degree
ORDER BY degree DESC
LIMIT $limit;

Incoming Edge GQL Template:

gql
MATCH (center:<NodeLabel>)<-[:<EdgeType>]-(n:<NodeLabel>)
WITH center, COUNT(DISTINCT n) AS degree
WHERE degree >= $minDegree
RETURN center, degree
ORDER BY degree DESC
LIMIT $limit;

Parameters:

  • Degree threshold (minDegree): minimum neighbor count for star centers
  • Aggregation scale: global aggregation vs local aggregation
  • Direction: outgoing / incoming / undirected (in-degree vs out-degree vs total degree)
  • Limit size: small / large / no limit

T3.4 4-Clique

Generic Intent: Find complete subgraphs of size 4 (4-cliques) in the graph, where every pair of nodes in the clique is connected.

This query identifies 4-cliques, which are fully connected subgraphs of size 4. It is a highly demanding combinatorial query that measures pattern matching engine performance and join optimization over dense topological structures.

Template:

Note: This query can be extended to larger clique sizes by matching more nodes and specifying undirected edge relationships between all pairs of nodes, alongside inequality constraints to ensure all matched nodes are distinct.

gql
MATCH (a:<NodeLabel>)-[:<EdgeType>]-(b:<NodeLabel>),
      (a)-[:<EdgeType>]-(c:<NodeLabel>),
      (a)-[:<EdgeType>]-(d:<NodeLabel>),
      (b)-[:<EdgeType>]-(c:<NodeLabel>),
      (b)-[:<EdgeType>]-(d:<NodeLabel>),
      (c)-[:<EdgeType>]-(d:<NodeLabel>)
WHERE a <> b AND a <> c AND a <> d AND b <> c AND b <> d AND c <> d
RETURN DISTINCT a, b, c, d
LIMIT $limit;

Parameters:

  • Clustering density: high-clustering vs low-clustering regions
  • Limit size: small / large / no limit

T3.5 Two-hop Join Pattern

Generic Intent: Find pairs of nodes connected through an intermediate node.

This query matches pairs of nodes that share a common neighbor. It evaluates intermediate node traversal, join optimization, and result deduplication.

Undirected Edge GQL Template:

gql
MATCH (a:<NodeLabel>)-[:<EdgeType>]-(middle:<NodeLabel>)-[:<EdgeType>]-(b:<NodeLabel>)
WHERE a <> b
RETURN a, middle, b
LIMIT $limit;

T3.6 Line Pattern

Generic Intent: Find pairs of nodes connected through a line relation with more than 2 hops.

This query matches longer simple path patterns between endpoint nodes. It evaluates chained traversal, intermediate result growth, and path distinctness constraints across multi-hop line relations.

GQL Template:

Note: The direction of each edge can be a parameter, so every hop in the line can independently be outgoing, incoming, or undirected.

gql
MATCH p = (a:<NodeLabel>)-[:<EdgeType1>]-(b:<NodeLabel>)-[:<EdgeType2>]-(c:<NodeLabel>)-[:<EdgeType3>]-(d:<NodeLabel>)
WHERE a <> b AND a <> c AND a <> d AND b <> c AND b <> d AND c <> d
RETURN a, d, p
LIMIT $limit;

Parameters:

  • Path length: 3 or more hops
  • Direction: each edge can independently be outgoing / incoming / undirected
  • Edge types: same edge type across all hops vs different edge types per hop
  • Limit size: small / large / no limit