Expand description
Pathfinding — BFS / DFS orders, shortest paths (unweighted BFS + weighted
Dijkstra), and all simple paths between two nodes. Directed (over the out view);
pass an Adjacency built from undirected-doubled edges for undirected search.
Functions§
- all_
simple_ paths - All simple paths from
stot(no repeated node), each up tomax_lennodes long (a guard against exponential blow-up on dense graphs). Directed. - bfs
- BFS order from
sover the directedoutview (nodes in the order first visited). Includessfirst. - dfs
- DFS pre-order from
sover the directedoutview (lowest-index neighbour first, so it’s deterministic). Includessfirst. - dijkstra
- Weighted shortest path (Dijkstra) from
stotover the directedoutview. Edge weights must be non-negative. Returns(path, cost)orNone. - shortest_
path - Unweighted shortest path (BFS) from
stotover the directedoutview. Returns the node sequence[s, …, t], orNoneiftis unreachable.