I programmatically generate many large undirected graphs. Sometimes these graphs are multigraphs, that is, they contain more than one edge between a pair of nodes. I've tried to delete the "extra" edges, to keep only one per node pair, with no success. It should be trivial, but I can't find a simple solution.
Take for instance, the following simple graph:
G0 = Graph[{a <-> b, b <-> c, c <-> a, b <-> a, b <-> c, b <-> a},
VertexLabels -> All]
How to keep only one edge between a
and b
, and one edge between c
and b
?
I've tried some very inefficient ways, but no success. I'd like to know if there's a simple solution (since the problem seems trivial at glance).
Note: If there are self-loops, I'd still like to keep them, therefore SimpleGraph[]
is not a solution for this particular problem.
Thank you,
Pedro
DeleteDuplicates
. $\endgroup$