Ask Your Question
0

Deleting a matching from a graph

asked 2022-05-02 16:41:25 +0200

vidyarthi gravatar image

When I have a graph $G$ and a perfect matching given by G.matching() or by using the independent set in its line graph, I wish to know whether there is a method to delete the matching edges from the edge set of the graph. Like, I want to know a method that gives $G-M1$ for $M1$ being a matching in the graph. Is there any such method? Thanks beforehand..

edit retag flag offensive close merge delete

Comments

@DavidCoudert thanks! it works

vidyarthi gravatar imagevidyarthi ( 2022-05-02 18:26:16 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-05-02 17:45:14 +0200

G.matching() returns a list of edges, so you can do:

sage: G = graphs.PetersenGraph()
sage: G.order(), G.size()
(10, 15)
sage: M = G.matching()
sage: G.delete_edges(M)
sage: G.order(), G.size()
(10, 10)
edit flag offensive delete link more

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: 2022-05-02 16:41:25 +0200

Seen: 173 times

Last updated: May 02 '22