I want to find all the possible pairs of nodes that do not have an edge connecting them and then check if these pairs of nodes have an edge in another graph. Any suggestions?
If you don't care for performance then you can try:
g1Edges = Graph1.edges()
notG1Edges = set()
for a in Graph1.nodes():
for b in Graph1.nodes():
if a != b and (a,b) not in g1Edges:
notG1Edges.add( (a, b) )
# print edges missed in Graph1 and Graph2
print notG1Edges.difference( Graph2.edges_iter() )
NOTE1: this is for directed graphs
NOTE2: if you want to find subset of edges from Graph2 not present in Graph1 then suppose it's better to operate on edges from Graph2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With