nocad.design.maximum_matching_min#
- nocad.design.maximum_matching_min(adj)[source]#
Matching whose unmatched nodes are a minimum set of dedicated driver nodes.
- Returns:
- matched, unmatched
ndarray - matched_by
ndarrayofshape(N,) - removable
scipy.sparse.csr_array Matched edges removed to open source SCCs that no unmatched node reaches.
- matched, unmatched
Notes
Let \(\beta\) be the number of source SCCs. Extend the bipartite graph by a slack out-vertex \(s_k\) per source SCC \(\mathcal{C}_k\), joined to the in-copies of its nodes. A maximum matching \(\mathcal{M}'\) of the extended graph selects a matching of \(\mathcal{G}\) and, for as many source SCCs as possible, a distinct node of the SCC left unmatched by it. The unmatched nodes plus one node of every source SCC that is still not hit form a set of dedicated driver nodes of size
\[N_D^{\min} = N + \beta - |\mathcal{M}'|,\]which is minimal: any valid driver set contains the unmatched nodes of some matching (no dilation) and a node of every source SCC (accessibility). In the unhit SCCs one matched edge is removed, so that every driver node is the start of a stem.
Examples
>>> # two cycles feeding a sink: path finding uses 2 drivers, so does the optimum >>> adj = [[0, 1, 0, 0, 0], [1, 0, 0, 0, 1], [0, 0, 0, 1, 0], [0, 0, 1, 0, 1], [0, 0, 0, 0, 0]] >>> maximum_matching_min(adj)[1] array([0, 2])