Determining if a graph is a subgraph of another graph
153 views
Skip to first unread message
Kamran Soomro
unread,
Feb 24, 2013, 6:04:06 AM2/24/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pygraphvi...@googlegroups.com
Hi,
I want to determine if a particular graph is a subgraph of another graph using networkx. How can I achieve this? Please note I am NOT looking to determine isomorphic subgraphs. I want the answer to be true if and only if the smaller graph is an actual subgraph. E.g.
G1 = A -> B -> C
G2 = B -> C
(Result should be true)
G1 = A -> B -> C
G2 = C -> D
(Result should be false)
Thanks.
Daniel Schult
unread,
Feb 24, 2013, 8:47:50 AM2/24/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pygraphvi...@googlegroups.com
Can you first check that each node in the subgraph is in the graph and then check that each edge of the subgraph is in the graph? [using "n in G" and G.has_edge(n1,n2)]
Kamran Soomro
unread,
Feb 24, 2013, 8:57:55 AM2/24/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pygraphvi...@googlegroups.com
Hi Daniel,
I figured it out. The node_match function is what I needed to achieve what I wanted to do.