@@ -556,6 +556,7 @@ private void removeNodes() {
556556 Set <SmartGraphVertexNode <V >> verticesToRemove = new HashSet <>();
557557 Set <SmartGraphEdgeBase > edgesToRemove = new HashSet <>();
558558
559+ //filter vertices to remove and their adjacent edges
559560 for (Vertex <V > v : removedVertices ) {
560561
561562 for (SmartGraphEdgeBase edge : values ) {
@@ -581,6 +582,14 @@ private void removeNodes() {
581582 vertexNodes .remove (v .getUnderlyingVertex ());
582583 removeVertice (v );
583584 }
585+
586+ //permanently remove remaining edges that were removed from the underlying graph
587+ Collection <Edge <E , V >> removedEdges = removedEdges ();
588+ for (Edge <E , V > e : removedEdges ) {
589+ SmartGraphEdgeBase edgeToRemove = edgeNodes .get (e );
590+ edgeNodes .remove (e );
591+ removeEdge (edgeToRemove );
592+ }
584593
585594 //remove adjacencies from remaining vertices
586595 for (SmartGraphVertexNode <V > v : vertexNodes .values ()) {
@@ -739,7 +748,7 @@ private Collection<Vertex<V>> unplottedVertices() {
739748 }
740749
741750 /**
742- * Computes the vertex collection that are currently being displayed but do
751+ * Computes the collection for vertices that are currently being displayed but do
743752 * not longer exist in the underlying graph.
744753 *
745754 * @return collection of vertices
@@ -758,6 +767,27 @@ private Collection<Vertex<V>> removedVertices() {
758767
759768 return removed ;
760769 }
770+
771+ /**
772+ * Computes the collection for edges that are currently being displayed but do
773+ * not longer exist in the underlying graph.
774+ *
775+ * @return collection of edges
776+ */
777+ private Collection <Edge <E , V >> removedEdges () {
778+ List <Edge <E , V >> removed = new LinkedList <>();
779+
780+ Collection <Edge <E , V >> graphEdges = theGraph .edges ();
781+ Collection <SmartGraphEdgeBase > plotted = edgeNodes .values ();
782+
783+ for (SmartGraphEdgeBase e : plotted ) {
784+ if (!graphEdges .contains (e .getUnderlyingEdge ())) {
785+ removed .add (e .getUnderlyingEdge ());
786+ }
787+ }
788+
789+ return removed ;
790+ }
761791
762792 /**
763793 * Computes the edge collection of the underlying graph that are not
0 commit comments