Skip to content

Graph

Tree techniques, graph decompositions, matching, and path algorithms.

Header Summary
bipartite_matching.hpp Dense bipartite matching using bitset-accelerated augmenting paths.
cycle.hpp Detect whether a directed graph contains a cycle.
dsu_on_tree.hpp DSU on tree. add(u) adds vertex u, query(u, x) queries contribution of x to u, del(u) removes vertex u.
heavy_light_decomposition.hpp Heavy-light decomposition for path and subtree queries on trees.
hungarian.hpp Hungarian algorithm. @return (cost, match, X-potential, Y-potential).
lowest_common_ancestor.hpp Sparse-table-based LCA with O(n log n) build and O(1) query.
manhattan_mst.hpp Compute candidate edges for Manhattan MST in O(n log n).
minimum_spanning_tree.hpp Kruskal's MST. Edges are (w, u, v). @return (cost, edge indices).
rooted_tree_isomorphism.hpp Assign canonical hash labels to rooted subtrees for isomorphism testing.
shortest_path.hpp BFS on unweighted graph. @return (distances, predecessors).
tree_diameter.hpp Unweighted tree diameter via double BFS. @return (diameter, u, v, eccentricity[]).