mathlib — Graph

Dijkstra, A*, D* Lite, vertex coloring, BFS/DFS. ← Back to hub

Pathfinding

1 Dijkstra, A*, D* Lite

Build graph from edges [u, v, w]; run Dijkstra, A*, or D* Lite from source; show distances and path to target.

Edge weights in gray; shortest path in blue.
—
Coloring

2 Vertex coloring

Greedy and DSatur coloring; bipartite check.

Vertex colors from greedy, DSatur, or bipartite.
—
Tree traversals

3 BFS / DFS

Breadth-first and depth-first traversal from a source.

Visit order and depth (BFS) or order (DFS).
—
Grid pathfinding

4 Grid pathfinding

4-connected grid with edge weights. Source (green S) = top-left, target (red T) = bottom-right. Edges colored by weight: green = low cost, red = high cost (e.g. 1000). Shortest path in blue. A* runs in Rust/WASM.

— new random weights (1–9 and some 1000 barriers).

Weights on edges; path in blue; legend shows weight range (low → high).
—