Create Graph from Missing Edges

Hello everyone,

I'm curious as to whether it is possible to compare two graphs (g2 and g1)
and build a graph object from the edges g2 has but g1 misses? In other
words, create a graph object out of the edges in g2 that are unique to it
compared to the edges in g1, given that both g1 and g2 have sources and
targets that are the same. Ideally, it would be interesting to see how to do
that regardless of whether someone is a source or a target in either graph
(undirected).

I know there is likely an involved way of doing this, but I'm wondering
whether there is a novel approach to take. Any ideas? Thank you for your
time.

This seems pretty simple. Assuming the mapping between the vertices of
g1, g2 and gdiff are given by their indexes, this is a simple loop:

    gdiff = Graph()
    gdiff.add_vertex(g1.num_vertices())

    for e in g2.edges():
        s, t = e
        e1 = g1.edge(int(s), int(t))
        if e1 is None:
            gdiff.add_edge(int(s), int(t))

Also take a look at the topology.similarity() function.

Cheers,
Tiago