Skip to main content

Module functions

Module functions 

Source
Expand description

Advanced graph algorithm implementations.

Functions§

bellman_ford
Bellman-Ford algorithm for single-source shortest paths (allows negative weights).
bipartite_matching
Hopcroft-Karp bipartite matching.
chromatic_number_approx
Greedy approximation of the chromatic number (treats graph as undirected).
dijkstra
Dijkstra’s algorithm for single-source shortest paths (non-negative weights).
floyd_warshall
Floyd-Warshall all-pairs shortest paths with path reconstruction.
is_bipartite
Check if the graph is bipartite using BFS 2-coloring.
kruskal_mst
Kruskal’s MST algorithm on an undirected weighted graph given as an edge list.
max_flow_bfs
Edmonds-Karp max-flow (BFS-based Ford-Fulkerson on FlowNetwork).
min_cut
Compute the S/T partition (min-cut) after running max_flow_bfs.
prim_mst
Prim’s MST algorithm on a weighted directed graph.
tarjan_scc
Tarjan’s strongly connected components algorithm.
topological_sort_dag
Topological sort of a DAG using Kahn’s algorithm (BFS).