← Back to the previous page

Neighborhood Workload

Queries that find neighbors of nodes.

Queries

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

T1.1 One-Hop Neighbors

Generic Intent: Find direct (1-hop) neighbors of a given start node.

This query tests fundamental local traversal performance, adjacency-list access speed, fanout behavior, and incoming/outgoing edge lookup efficiency for a single hop.

Undirected Edge GQL Template:

gql
MATCH (s:<NodeLabel1> {<idProp>: $startId})-[:<EdgeType>]-(n:<NodeLabel2>)
RETURN n
LIMIT $limit;

Outgoing Edge GQL Template:

gql
MATCH (s:<NodeLabel1> {<idProp>: $startId})-[:<EdgeType>]->(n:<NodeLabel2>)
RETURN n
LIMIT $limit;

Incoming Edge GQL Template:

gql
MATCH (s:<NodeLabel1> {<idProp>: $startId})<-[:<EdgeType>]-(n:<NodeLabel2>)
RETURN n
LIMIT $limit;

Parameters:

  • Start node (degree): low / medium / high (measures scalability of start node's fanout)
  • Direction: outgoing / incoming / undirected
  • Limit size: small / large / no limit

T1.2 k-Hop Neighborhood

Generic Intent: Find all distinct nodes reachable within a range of 1 to k hops from a start node.

This query evaluates multi-hop local traversal performance, path expansion, and memory overhead as the traversal frontier grows. It also measures the database's efficiency in removing duplicate nodes encountered along different paths.

Undirected Edge GQL Template:

gql
MATCH p = (s:<NodeLabel1> {<idProp>: $startId})-[:<EdgeType>]-{1,<k>}(n:<NodeLabel2>)
RETURN DISTINCT n
LIMIT $limit;

Outgoing Edge GQL Template:

gql
MATCH p = (s:<NodeLabel1> {<idProp>: $startId})-[:<EdgeType>]->{1,<k>}(n:<NodeLabel2>)
RETURN DISTINCT n
LIMIT $limit;

Incoming Edge GQL Template:

gql
MATCH p = (s:<NodeLabel1> {<idProp>: $startId})<-[:<EdgeType>]-{1,<k>}(n:<NodeLabel2>)
RETURN DISTINCT n
LIMIT $limit;

Parameters:

  • Depth bound (k): 2, 3, 4, 5
  • Start node (degree): low / medium / high (measures scalability of start node's fanout)
  • Direction: outgoing / incoming / undirected
  • Limit size: small / large / no limit

T1.3 Exact kth-Hop Neighbors

Generic Intent: Find nodes that are exactly k hops away from a start node.

Unlike the general k-Hop Neighborhood query which returns all nodes reachable within the range of 1 to k, this query isolates only the nodes at the precise boundary of k hops, filtering out nodes that can be reached in fewer hops.

Undirected Edge GQL Template:

gql
MATCH (s:<NodeLabel> {<idProp>: $startId})-[:<EdgeType>]-{<k>}(n:<NodeLabel>)
RETURN DISTINCT n
LIMIT $limit;

Outgoing Edge GQL Template:

gql
MATCH (s:<NodeLabel> {<idProp>: $startId})-[:<EdgeType>]->{<k>}(n:<NodeLabel>)
RETURN DISTINCT n
LIMIT $limit;

Incoming Edge GQL Template:

gql
MATCH (s:<NodeLabel> {<idProp>: $startId})<-[:<EdgeType>]-{<k>}(n:<NodeLabel>)
RETURN DISTINCT n
LIMIT $limit;

Parameters:

  • Precise distance (k): 2, 3, 4, 5
  • Start node (degree): low / medium / high (measures scalability of start node's fanout)
  • Direction: outgoing / incoming / undirected
  • Limit size: small / large / no limit

T1.4 Neighborhood with Property Filter

Generic Intent: Find nearby nodes or edges satisfying a specific predicate.

This query combines multi-hop local traversal with filters, testing the graph query optimizer's efficiency. It measures whether the engine can push filters down during traversal expansion or if it performs a costly post-filtering step on the fully expanded neighborhood.

Node-Filtered GQL - Undirected Edge:

gql
MATCH (s:<NodeLabel> {<idProp>: $startId})-[e:<EdgeType>]-{1,<k>}(n:<NodeLabel>)
WHERE n.<nodeFilterProp> = $nodeFilterValue
RETURN DISTINCT n
LIMIT $limit;

Node-Filtered GQL - Outgoing Edge:

gql
MATCH (s:<NodeLabel> {<idProp>: $startId})-[e:<EdgeType>]->{1,<k>}(n:<NodeLabel>)
WHERE n.<nodeFilterProp> = $nodeFilterValue
RETURN DISTINCT n
LIMIT $limit;

Node-Filtered GQL - Incoming Edge:

gql
MATCH (s:<NodeLabel> {<idProp>: $startId})<-[e:<EdgeType>]-{1,<k>}(n:<NodeLabel>)
WHERE n.<nodeFilterProp> = $nodeFilterValue
RETURN DISTINCT n
LIMIT $limit;

Edge-Filtered GQL - Undirected Edge:

gql
MATCH (s:<NodeLabel> {<idProp>: $startId})-[e:<EdgeType>]-(n:<NodeLabel>)
WHERE e.<edgeFilterProp> >= $threshold
RETURN n
LIMIT $limit;

Edge-Filtered GQL - Outgoing Edge:

gql
MATCH (s:<NodeLabel> {<idProp>: $startId})-[e:<EdgeType>]->(n:<NodeLabel>)
WHERE e.<edgeFilterProp> >= $threshold
RETURN n
LIMIT $limit;

Edge-Filtered GQL - Incoming Edge:

gql
MATCH (s:<NodeLabel> {<idProp>: $startId})<-[e:<EdgeType>]-(n:<NodeLabel>)
WHERE e.<edgeFilterProp> >= $threshold
RETURN n
LIMIT $limit;

Parameters:

  • Filter selectivity: high / medium / low selectivity
  • Filter location: node property filter vs edge property filter
  • Start node (degree): low / medium / high (measures scalability of start node's fanout)
  • Direction: outgoing / incoming / undirected
  • Limit size: small / large / no limit