nocad.design.maximum_matching_pf#
- nocad.design.maximum_matching_pf(adj)[source]#
Maximum matching corrected by the path-finding method (MATLAB
maximumMatchingPF).- Parameters:
- adjarray_like or
sparse,shape(N,N)
- adjarray_like or
- Returns:
- matched
ndarray Nodes with an incoming matched edge.
- unmatched
ndarray Driver nodes (one dedicated input each).
- matched_by
ndarrayofshape(N,) matched_by[i] = jif \(x_j\to x_i\) is matched,-1otherwise.- removable
scipy.sparse.csr_arrayofshape(N,N) Matched edges removed from the maximum matching to open source SCCs.
- matched
Notes
For every nontrivial strongly connected component without incoming edges whose nodes are all matched (a matched source SCC, covered by cycles of the matching):
if it points to an unmatched node \(x_k\) through an edge \(x_j\to x_k\), the matched edge \(x_j\to x_i\) inside the SCC is exchanged for \(x_j\to x_k\); \(x_i\) becomes the driver node and the stem continues through the SCC into \(x_k\) (the number of drivers does not change);
otherwise one matched edge inside the SCC is removed (one more driver node).
The SCCs are processed one after the other (greedily), as in the MATLAB toolbox.
References
[1]D. Leitold, Á. Vathy-Fogarassy, J. Abonyi, “Controllability and observability in complex networks – the effect of connection types”, Scientific Reports 7 (2017) 151.
Examples
>>> adj = [[0, 1, 0, 0], [0, 0, 1, 0], [1, 0, 0, 1], [0, 0, 0, 0]] >>> matched, unmatched, matched_by, removable = maximum_matching_pf(adj) >>> unmatched, matched_by (array([0]), array([-1, 0, 1, 2]))