Ask Your Question
0

How to compute a perfect matching in a general graph?

asked 5 years ago

Ganapati Natarajan gravatar image

Are there functions to compute a maximal or perfect matching, or all the maximal/perfect matchings in a general (bipartite or non-bipartite) graph

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
0

answered 5 years ago

tmonteil gravatar image

If you just want a perfect matching, you can use:

sage: p = G.matching()

If you want to iterate over all parfect matching, you can use (but it might be very slow as it is a brute force approach):

sage: for p in G.perfect_matchings():
....:     blah
Preview: (hide)
link
0

answered 5 years ago

dazedANDconfused gravatar image

You should download the PDF documentation which is available here. On page 222 there are 3 listed:

  1. matching() Return a maximum weighted matching of the graph represented by the list of its edges.
  2. has_perfect_matching() Return whether this graph has a perfect matching
  3. perfect_matchings() Return an iterator over all perfect matchings of the graph.

Clicking on each method will bring you to more instructions and examples.

Preview: (hide)
link

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 5 years ago

Seen: 593 times

Last updated: Jul 29 '19