Lets say I have an undirected graph G. Lets say I add the following
add_edge(1,2,G);
add_edge(1,3,G);
add_edge(0,2,G);
Now I lets say add this again:
add_edge(0,2,G);
Do I have two edges in my graph from 0 ---> 2 ?
What happens if I added the edge twice and I do:
remove_edge(0,2,G);
Do both the edges disappear,or do I still have one of them?
The answer to both of your questions depends on the definition of graph G.
The answer to the first question, according to the boost::graph tutorial, depends on which OutEdgeList
you use in your graph definition. If you use a container that cannot represent multiple edges (such as setS
or hash_setS
), there will be only one edge between two vertices no matter how many times you insert it. If you use a vectorS
, multisetS
or similar, there will be one edge inserted for each call of add_edge()
.
The answer to the second question, according to the same page (that section of the page does not allow direct links - just search for remove_edge
) is that all edges between the two vertices will be removed after calling that particular remove_edge()
function. There are several other versions of remove_edge()
(described on the same page), each with a slightly different behaviour.
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