export declare type Edge = { from: T; to: T; capacity: number; cost: number; flow?: number; }; declare type DestringifyOptions = { source?: string; sink?: string; }; declare type MinCostFlowOptions = { desiredFlow?: number; } & DestringifyOptions; /** * Solves a minimum-cost flow problem using the successive shortest paths algorithm. Assumes that only one edge goes * between any two nodes – in either direction. In other words: no double edges in the same direction, and no back * edges. * * The function is a wrapper that destringifies the graph, calls minCostFlowForNumberNodes on it and restringifies the * result. * * @param {Array>} graph The graph represented as an edge list * @param {MinCostFlowOptions} options An object with three keys: source (string), sink (string) and * desiredFlow (number). Source is `"SOURCE"` by default, sink is `"SINK"` by default and desiredFlow is `Infinity` by * default (indicating a desire for maximum flow). * @returns {Array>>} */ export declare function minCostFlow(graph: Array>, options?: MinCostFlowOptions): Array>>; /** * The underlying implementation of the successive shortest paths algorithm, nabbed from * * Assumptions: * - The nodes are sequentially numbered integers from 0 to (but not including) n. * - Node 0 is the source, node n-1 is the sink. * - Only one edge goes between any two nodes – in either direction. In other words: no double edges in the same direction, and no back edges. * * @param {Array>} graph The graph represented as an edge list * @param {number} desiredFlow The maximum flow you want; the algorithm stops when it reaches this number. Default is Infinity, indicating a desire for maximum flow. * @returns {Array>} The network updated to provide as much flow up to the limit specified by desiredFlow */ export declare function minCostFlowForNumberNodes(graph: Array>, desiredFlow?: number): Array>>; /** * Takes a graph with edges edges going to and from nodes with string names and transforms it into a graph with numbered edges, * following the convention that the source node is the first node and the sink node the last. * It assumes that the source node's name is SOURCE and the sink node's name is SINK. * * @param {Array>} graph A graph in the form of an edge list * @param {{source: (string|undefined), sink: (string|undefined)}} options An object with two (optional) keys: source and sink. * If a value is supplied at this key, the function will assume that the source/sink node's name is equal to the supplied value. * @returns {Array} A two element tuple whose first element is the destringified graph and whose second element is the node names listed in the order in which they were named, so that the graph can be restringified by getting nodeNames[n] for any node in the destringified graph. */ export declare function destringifyGraph(graph: Array>, options?: DestringifyOptions): [Array>, string[]]; /** * Restringifies a graph that has been destringified by destringifyGraph * * @param {Array>} graph The graph as an edge list * @param {string[]} nodeNames The names of each node, so that the name of the node numbered `x` can be found at `nodeNames[x]` * @returns {Array>} The restringified graph */ export declare function restringifyGraph(graph: Array>, nodeNames: string[]): Array>; declare type BipartiteEdge = { left: string; right: string; weight: number; }; /** * Finds a minimum weight bipartite match for a graph. * * Converts the problem to a minimum-cost flow problem. * * @param {BipartiteEdge[]} edges The entire weighted graph represented as weighted edges * @returns {BipartiteEdge[]} The edges that are part of the minimum bipartite match */ export declare function minimumWeightBipartiteMatch(edges: BipartiteEdge[]): BipartiteEdge[]; export {};