Network Diameter

Hello There,

I would like to take into account the network diameter for being able to filter all the networks by network diameter size. Is that doable ?

Thanks in advance !

Hello @1113 :slight_smile:

Do you want to calculate the diameter of the graph? It corresponds to the longest of the shortest paths. Be aware that the calculation can be very long. You can add filters for nodes and relationships if you want the query to be faster.

WITH collect(n) AS nodes
UNWIND nodes AS a
UNWIND nodes AS b
WITH a, b
WHERE id(a) < id(b)
MATCH path=shortestPath((a)-[*]-(b))
RETURN length(path) AS diameter
ORDER BY diameter


Thank you, The graph I would like to analyse is around 700k nodes. The command is running. I will keep you posted. :-)

Do you want to analyse all nodes and relationships or only some labels and types?