@graphty/algorithms
Version:
Graph algorithms library for browser environments implemented in TypeScript
37 lines • 1.38 kB
TypeScript
import type { Graph } from "../../core/graph.js";
import type { NodeId } from "../../types/index.js";
/**
* Maximum Bipartite Matching implementation using Hopcroft-Karp algorithm
*
* Finds the maximum matching in a bipartite graph. A matching is a set of edges
* without common vertices. Maximum matching has the largest possible number of edges.
*
* Time complexity: O(√V × E)
* Space complexity: O(V)
*/
export interface BipartiteMatchingResult {
matching: Map<NodeId, NodeId>;
size: number;
}
export interface BipartiteMatchingOptions {
leftNodes?: Set<NodeId>;
rightNodes?: Set<NodeId>;
}
/**
* Find maximum matching in a bipartite graph using augmenting path algorithm
* (simplified implementation that's more reliable than Hopcroft-Karp for this context)
*/
export declare function maximumBipartiteMatching(graph: Graph, options?: BipartiteMatchingOptions): BipartiteMatchingResult;
/**
* Check if graph is bipartite and return the partition
*/
export declare function bipartitePartition(graph: Graph): {
left: Set<NodeId>;
right: Set<NodeId>;
} | null;
/**
* Simple greedy bipartite matching algorithm
* Useful for comparison or when Hopcroft-Karp is overkill
*/
export declare function greedyBipartiteMatching(graph: Graph, options?: BipartiteMatchingOptions): BipartiteMatchingResult;
//# sourceMappingURL=bipartite.d.ts.map