Skip to main content

Module path

Module path 

Source
Expand description

Weighted shortest path via Dijkstra.

Edge weight is relationship strength (higher = stronger), but shortest path minimizes distance. We convert with distance = -ln(weight): a perfect edge (weight 1.0) costs 0, a weak edge costs more, and weight → 0 tends to infinity (the edge becomes impassable). This turns products of edge strengths along a path into a sum of costs, so a path of two strong edges can legitimately beat one weak edge — matching the shortestPath semantics of Neo4j/GDS.

Constants§

SHORTEST_PATH_W_MIN
Edge weights at or below this are treated as impassable (infinite distance).

Functions§

dijkstra
Dijkstra from src, returning (node_index, distance) for every reachable node, sorted by distance ascending. src itself appears with distance 0.0.
shortest_path
Cheapest path from src to dst as a node-index sequence, or None if unreachable (or either endpoint is out of range).
shortest_path_ids
Build a CSR snapshot from conn and resolve a path between two node IDs.