graphstream / gs-core

Graphstream core
http://graphstream-project.org/
Other
398 stars 109 forks source link

AdjacencyListGraph does not check existence of a node/edge before shrinking array #338

Closed cbruegg closed 3 years ago

cbruegg commented 4 years ago

When calling AdjacencyListGraph.removeNode(n) with a node n not present in the graph, it proceeds to call removeNodeCallback(n). Despite nodeMap.remove(...) being a no-op in this case, the nodeArray loses the element in nodeArray[node.getIndex()], which may actually also cause an ArrayOutOfBoundsException. The proposed change fixes this by checking if nodeMap.remove(...) actually found the node or not.

The same was done for edges.