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.
When calling
AdjacencyListGraph.removeNode(n)
with a noden
not present in the graph, it proceeds to callremoveNodeCallback(n)
. DespitenodeMap.remove(...)
being a no-op in this case, thenodeArray
loses the element innodeArray[node.getIndex()]
, which may actually also cause anArrayOutOfBoundsException
. The proposed change fixes this by checking ifnodeMap.remove(...)
actually found the node or not.The same was done for edges.