Reading — step 1 of 5
Read
Shortest Path
Common graph queries:
Unweighted shortest path: BFS.
O(V + E).
Weighted shortest path: Dijkstra.
O((V + E) log V).
A*: Dijkstra with heuristic. Faster when goal is known.
Bidirectional: search from both ends; meet in the middle. ~2x speedup.
All-pairs shortest path (Floyd-Warshall): O(V³). Used for small graphs.
In Cypher:
MATCH p = shortestPath((a:Person {name: 'Alice'})-[*]-(b:Person {name: 'Bob'}))
RETURN p
PageRank (recursive importance):
PR(v) = (1-d)/N + d * sum(PR(u) / out_degree(u) for u in incoming(v))
Solved by iteration until convergence. d = 0.85 typical.
Community detection: Louvain, Label Propagation. Find clusters of densely-connected nodes.
Centrality: betweenness (how often node lies on shortest paths), closeness (avg shortest path length to all others).
These are the staple algorithms. Graph DBs typically include them as built-in functions or via Graph Data Science (GDS) plugins.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…