Ask Your Question

# Check SDR in a bipartite graph by Hall's theorem.

How can I check existence of a complete SDR in a bipartite graph ?

This will be done by checking if there is a perfect matching in the graph(Hall's marriage theorem), but How can I implement this in SAGE?

edit retag close merge delete

## 1 Answer

Sort by » oldest newest most voted

You can ask for a maximal matching and see if its size correspond to half the size of the bipartite graph:

You can get a maximal matching as follows:

sage: n = 10
sage: G = graphs.RandomBipartite(n,n,0.5)
sage: G.matching()
[((0, 1), (1, 0), None),
((0, 6), (1, 7), None),
((0, 4), (1, 4), None),
((0, 7), (1, 8), None),
((0, 9), (1, 9), None),
((0, 0), (1, 2), None),
((0, 5), (1, 6), None),
((0, 3), (1, 1), None),
((0, 8), (1, 5), None),
((0, 2), (1, 3), None)]


You can check that a maximal matching is complete as follows:

sage: len(G.matching()) == n
True


or as follows:

sage: G.matching(value_only=True) == n
True

more

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2015-12-07 17:39:04 +0200

Seen: 512 times

Last updated: Dec 07 '15