I have a for loop that adds edges to a graph g
, but I also want the graph to add loops. How can I do this, for a general graph whose structure I do not know (that is, I want to add the loop to a graph, rather than make a new graph)?
I've tried using the g.add_edge
function, then g.merge_vertices
to contract a cycle to a loop, but to no avail. Sage justs simplifies the graph.
Any approach to this would be appreciated, direct or indirect.