public boolean add ( WeightedEdge e ) { int toAdd = - 1 ; if ( e . from ( ) == rootVertex ) toAdd = e . to ( ) ; else if ( e . to ( ) == rootVertex ) toAdd = e . from ( ) ; else { return false ; } double w = e . weight ( ) ; if ( edges . containsKey ( toAdd ) ) { double w2 = edges . put ( toAdd , w ) ; // The weight was changed but a new edge was not added return false ; } else { edges . put ( toAdd , w ) ; return true ; } }
Adds the edge to this set if one of the vertices is the root vertex .