On Wednesday, 15 May 2013 at 17:59:01 UTC, Joseph Rushton
Wakeling wrote:
Maybe I'm being harsh, but I was assuming you might actually
throw an error if
someone tries to add an edge that already exists (although
perhaps you'd want to
avoid throwing in order not to hit performance).
I don't think that's too useful or necessary. A graph is at its
heart a pair (V, E) where V is the vertex set and E is the edge
set. So addNode is really just V' = V ∪ {n} for some node n. I
think it's best to just allow redundantly adding a node, which
ought to be an O(1) function.