nocad.matching.maximum_matching#

nocad.matching.maximum_matching(adj)[source]#

Maximum matching of a directed network (Hopcroft–Karp).

Parameters:
adjarray_like or sparse, shape (N, N)

Adjacency matrix, adj[j, i] != 0 iff \(x_j\to x_i\).

Returns:
Matching

Notes

The directed matching is the maximum matching of the bipartite graph \((\{x_j^+\},\{x_i^-\},\mathcal{E})\); SciPy’s Hopcroft–Karp implementation runs in \(O(|\mathcal{E}|\sqrt{N})\). The unmatched nodes are the driver nodes of the minimum input theorem [1]; the unmatched nodes of the reversed network are the sensor nodes [2].

References

[1]

Y.-Y. Liu, J.-J. Slotine, A.-L. Barabási, “Controllability of complex networks”, Nature 473 (2011) 167–173.

[2]

Y.-Y. Liu, J.-J. Slotine, A.-L. Barabási, “Observability of complex systems”, PNAS 110 (2013) 2460–2465.

Examples

>>> m = maximum_matching([[0, 1, 0, 0], [0, 0, 1, 0], [1, 0, 0, 1], [0, 0, 0, 0]])
>>> m.size, m.unmatched
(3, array([3]))