Skip to main content
CALL statement in GQL invokes a Procedure

For each node find the number of incoming edges

Suppose we are interested in the number of highways flowing into each of the Highway: We can use the CALL statement to invoke and inline procedure as follows:
MATCH nodes = (b)
CALL {
  MATCH path = (a)-[e1:flows_to]->(b)
  return path
    , count(distinct e1) as incoming_nodes_count
    , COLLECT_LIST(distinct a.name) as incoming_nodes
}
return table(b.name, incoming_nodes_count, incoming_nodes)
order by incoming_nodes_count desc;

For each node list paths to all other nodes

We are interested in getting all paths from each to all other nodes:
MATCH nodes = (a)
CALL {
  MATCH path = (a)-[edges:flows_to]->{0,}(b)
  return reduce(path = a._id, edge in edges | path || '->' || edge._to) as route
  , b
  
}
return table(a.name as starting, b.name as ending, route)