Queries
Select a query type below to view its template and description.
T4.1 Ungrouped Node Degree Statistics by Label
Generic Intent: Compute ungrouped degree statistics (average, minimum, maximum, and total count) across all nodes of a given label.
This query first computes the degree of each node with a target label, optionally filtering by edge label but not by neighbor label or node property. It then summarizes those per-node degrees with global aggregate statistics.
Note: The edge label filter is optional; omit :<edgeLabel> to count all edge
labels.
Undirected Edge GQL Template:
MATCH (n:<NodeLabel>) OPTIONAL MATCH (n)-[:<edgeLabel>]-(m) WITH n, COUNT(DISTINCT m) AS degree RETURN COUNT(n) AS nodeCount, AVG(degree) AS avgDegree, MIN(degree) AS minDegree, MAX(degree) AS maxDegree;
Outgoing Edge GQL Template:
MATCH (n:<NodeLabel>) OPTIONAL MATCH (n)-[:<edgeLabel>]->(m) WITH n, COUNT(DISTINCT m) AS outDegree RETURN COUNT(n) AS nodeCount, AVG(outDegree) AS avgOutDegree, MIN(outDegree) AS minOutDegree, MAX(outDegree) AS maxOutDegree;
Incoming Edge GQL Template:
MATCH (n:<NodeLabel>) OPTIONAL MATCH (n)<-[:<edgeLabel>]-(m) WITH n, COUNT(DISTINCT m) AS inDegree RETURN COUNT(n) AS nodeCount, AVG(inDegree) AS avgInDegree, MIN(inDegree) AS minInDegree, MAX(inDegree) AS maxInDegree;
Parameters:
- Node label: target label for the nodes whose degrees are summarized
- Edge label: optional edge label filter
- Direction: outgoing / incoming / undirected
T4.2 Grouped Node Degree Statistics by Label
Generic Intent: Extend Q1 by grouping nodes by a property and computing degree statistics for each group.
This query computes degree statistics (node count, average, minimum, and maximum degrees) grouped by a specific node property. Nodes with no matching neighbors are retained with degree 0, so each group includes isolated or unmatched nodes. It evaluates group-by execution, aggregation performance, and sorting capabilities under property grouping.
Note: The edge label filter is optional; omit :<edgeLabel> to count all edge
labels.
Undirected Edge GQL Template:
MATCH (n:<NodeLabel1>) OPTIONAL MATCH (n)-[:<edgeLabel>]-(m:<NodeLabel2>) WITH n, COUNT(DISTINCT m) AS degree RETURN n.<groupProp> AS groupValue, COUNT(n) AS nodeCount, AVG(degree) AS avgDegree, MIN(degree) AS minDegree, MAX(degree) AS maxDegree ORDER BY avgDegree DESC LIMIT $limit;
Outgoing Edge GQL Template:
MATCH (n:<NodeLabel1>) OPTIONAL MATCH (n)-[:<edgeLabel>]->(m:<NodeLabel2>) WITH n, COUNT(DISTINCT m) AS outDegree RETURN n.<groupProp> AS groupValue, COUNT(n) AS nodeCount, AVG(outDegree) AS avgOutDegree, MIN(outDegree) AS minOutDegree, MAX(outDegree) AS maxOutDegree ORDER BY avgOutDegree DESC LIMIT $limit;
Incoming Edge GQL Template:
MATCH (n:<NodeLabel1>) OPTIONAL MATCH (n)<-[:<edgeLabel>]-(m:<NodeLabel2>) WITH n, COUNT(DISTINCT m) AS inDegree RETURN n.<groupProp> AS groupValue, COUNT(n) AS nodeCount, AVG(inDegree) AS avgInDegree, MIN(inDegree) AS minInDegree, MAX(inDegree) AS maxInDegree ORDER BY avgInDegree DESC LIMIT $limit;
Parameters:
- Group size: small / medium / large number of groups
- Group skew: uniform / Zipfian / highly skewed cardinality
- Aggregation types: COUNT, COUNT DISTINCT, AVG, MIN, MAX
- Selectivity: grouping property selectivity
- Edge label: optional edge label filter
- Direction: outgoing / incoming / undirected
T4.3 Ungrouped Edge Count and Property Statistics (Optional)
Generic Intent: Count matched edges and summarize the values of a numeric edge property.
This query aggregates over all edges that match the selected node labels and edge type. It returns the total edge count together with average, minimum, and maximum values for one numeric edge property, without grouping the result by node or edge properties. This query is optional because some datasets may not have numeric properties on their edges.
Undirected Edge GQL Template:
MATCH (src:<NodeLabel1>)-[e:<EdgeType>]-(dst:<NodeLabel2>) RETURN COUNT(e) AS edgeCount, AVG(e.<edgeNumericProp>) AS avgEdgeValue, MIN(e.<edgeNumericProp>) AS minEdgeValue, MAX(e.<edgeNumericProp>) AS maxEdgeValue;
Outgoing Edge GQL Template:
MATCH (src:<NodeLabel1>)-[e:<EdgeType>]->(dst:<NodeLabel2>) RETURN COUNT(e) AS edgeCount, AVG(e.<edgeNumericProp>) AS avgEdgeValue, MIN(e.<edgeNumericProp>) AS minEdgeValue, MAX(e.<edgeNumericProp>) AS maxEdgeValue;
Incoming Edge GQL Template:
MATCH (src:<NodeLabel1>)<-[e:<EdgeType>]-(dst:<NodeLabel2>) RETURN COUNT(e) AS edgeCount, AVG(e.<edgeNumericProp>) AS avgEdgeValue, MIN(e.<edgeNumericProp>) AS minEdgeValue, MAX(e.<edgeNumericProp>) AS maxEdgeValue;
Parameters:
- Edge label: selected edge type
- Node labels: source and destination labels used to select edges
- Numeric property: edge property summarized by AVG, MIN, and MAX
- Direction: outgoing / incoming / undirected
T4.4 Grouped Edge Count and Property Statistics (Optional)
Generic Intent: Extend Q3 by grouping matched edges and computing edge statistics for each group.
This query counts matched edges and summarizes a numeric edge property after grouping by source and destination node properties. It is the grouped version of Q3 and measures multidimensional aggregation, sorting, and top-K result materialization. This query is optional because some datasets may not have numeric properties on their edges.
Undirected Edge GQL Template:
MATCH (src:<NodeLabel1>)-[e:<EdgeType>]-(dst:<NodeLabel2>) RETURN src.<sourceGroupProp> AS sourceGroup, dst.<targetGroupProp> AS targetGroup, COUNT(e) AS edgeCount, AVG(e.<edgeNumericProp>) AS avgEdgeValue, MIN(e.<edgeNumericProp>) AS minEdgeValue, MAX(e.<edgeNumericProp>) AS maxEdgeValue ORDER BY edgeCount DESC LIMIT $limit;
Outgoing Edge GQL Template:
MATCH (src:<NodeLabel1>)-[e:<EdgeType>]->(dst:<NodeLabel2>) RETURN src.<sourceGroupProp> AS sourceGroup, dst.<targetGroupProp> AS targetGroup, COUNT(e) AS edgeCount, AVG(e.<edgeNumericProp>) AS avgEdgeValue, MIN(e.<edgeNumericProp>) AS minEdgeValue, MAX(e.<edgeNumericProp>) AS maxEdgeValue ORDER BY edgeCount DESC LIMIT $limit;
Incoming Edge GQL Template:
MATCH (src:<NodeLabel1>)<-[e:<EdgeType>]-(dst:<NodeLabel2>) RETURN src.<sourceGroupProp> AS sourceGroup, dst.<targetGroupProp> AS targetGroup, COUNT(e) AS edgeCount, AVG(e.<edgeNumericProp>) AS avgEdgeValue, MIN(e.<edgeNumericProp>) AS minEdgeValue, MAX(e.<edgeNumericProp>) AS maxEdgeValue ORDER BY edgeCount DESC LIMIT $limit;
Parameters:
- Dimensions: grouping by source property, destination property, or both
- Numeric property: edge property summarized by AVG, MIN, and MAX
- Ordering: sorting with or without ORDER BY
- Limit size: small / large / no limit
T4.5 Path Counts by Length
Generic Intent: Enumerate bounded-length paths and summarize how many paths and distinct target nodes appear at each path length.
This query finds paths up to a maximum length from a selected source node to matching target nodes. It groups results only by path length, returning the total number of paths and the number of distinct targets reached at each length. It measures path enumeration and aggregation over path length without grouping by target properties.
Undirected Edge GQL Template:
MATCH p = (s:<NodeLabel1> {<idProp>: $sourceId})-[:<EdgeType>]-{1,<k>}(t:<NodeLabel2>) RETURN length(p) AS pathLength, COUNT(p) AS pathCount, COUNT(DISTINCT t) AS distinctTargetCount ORDER BY pathLength ASC LIMIT $limit;
Outgoing Edge GQL Template:
MATCH p = (s:<NodeLabel1> {<idProp>: $sourceId})-[:<EdgeType>]->{1,<k>}(t:<NodeLabel2>) RETURN length(p) AS pathLength, COUNT(p) AS pathCount, COUNT(DISTINCT t) AS distinctTargetCount ORDER BY pathLength ASC LIMIT $limit;
Incoming Edge GQL Template:
MATCH p = (s:<NodeLabel1> {<idProp>: $sourceId})<-[:<EdgeType>]-{1,<k>}(t:<NodeLabel2>) RETURN length(p) AS pathLength, COUNT(p) AS pathCount, COUNT(DISTINCT t) AS distinctTargetCount ORDER BY pathLength ASC LIMIT $limit;
Parameters:
- Path limit (K): maximum path length (e.g., k = 2, 3, 4)
- Grouping: path length only
- Aggregation mode: count of total paths (COUNT(p)) vs distinct targets reached (COUNT(DISTINCT t))
- Limit size: small / large / no limit
T4.6 Grouped Path Counts by Length and Endpoint Type
Generic Intent: Extend Q5 by also grouping path counts by a target-node property.
This query finds paths up to a maximum length from a selected source node to matching target nodes. It groups results by both path length and a target-node property, returning the total number of paths and the number of distinct targets for each length-and-group combination. It measures path enumeration plus group-by aggregation over endpoint metadata.
Undirected Edge GQL Template:
MATCH p = (s:<NodeLabel1> {<idProp>: $sourceId})-[:<EdgeType>]-{1,<k>}(t:<NodeLabel2>) RETURN length(p) AS pathLength, t.<groupProp> AS targetGroup, COUNT(p) AS pathCount, COUNT(DISTINCT t) AS distinctTargetCount ORDER BY pathLength ASC, pathCount DESC LIMIT $limit;
Outgoing Edge GQL Template:
MATCH p = (s:<NodeLabel1> {<idProp>: $sourceId})-[:<EdgeType>]->{1,<k>}(t:<NodeLabel2>) RETURN length(p) AS pathLength, t.<groupProp> AS targetGroup, COUNT(p) AS pathCount, COUNT(DISTINCT t) AS distinctTargetCount ORDER BY pathLength ASC, pathCount DESC LIMIT $limit;
Incoming Edge GQL Template:
MATCH p = (s:<NodeLabel1> {<idProp>: $sourceId})<-[:<EdgeType>]-{1,<k>}(t:<NodeLabel2>) RETURN length(p) AS pathLength, t.<groupProp> AS targetGroup, COUNT(p) AS pathCount, COUNT(DISTINCT t) AS distinctTargetCount ORDER BY pathLength ASC, pathCount DESC LIMIT $limit;
Parameters:
- Path limit (K): maximum path length (e.g., k = 2, 3, 4)
- Group combinations: grouping by path length and target group
- Aggregation mode: count of total paths (COUNT(p)) vs distinct targets reached (COUNT(DISTINCT t))
- Limit size: small / large / no limit
T4.7 Union and Intersection
Generic Intent: Find the union or intersection of nodes who have neighbors with label value A and/or label value B.
This query finds source nodes connected to neighboring label-value nodes through one or more relationships. It can return nodes matching either label value, or only nodes that match both label values.
Intersection GQL Template:
MATCH (n:<NodeLabel>)-[:<EdgeType1>]->(m1:<NeighborLabel>)-[:<EdgeType2>]->(v1:<LabelValueNode> {<labelValueProp>: $labelValueA}) MATCH (n)-[:<EdgeType1>]->(m2:<NeighborLabel>)-[:<EdgeType2>]->(v2:<LabelValueNode> {<labelValueProp>: $labelValueB}) RETURN DISTINCT n LIMIT $limit;
Union GQL Template:
MATCH (n:<NodeLabel>)-[:<EdgeType1>]->(m:<NeighborLabel>)-[:<EdgeType2>]->(v:<LabelValueNode>) WHERE v.<labelValueProp> = $labelValueA OR v.<labelValueProp> = $labelValueB RETURN DISTINCT n LIMIT $limit;
Parameters:
- Set mode: union (OR) or intersection (AND)
- Label values: the two target label values, A and B
- Path shape: direct neighbor relation vs multi-hop relation through an intermediate node
- Direction: outgoing / incoming / undirected for each relationship in the path
- Limit size: small / large / no limit