#82 Can't add edges to a graph after deleting node 0

open
nobody
None
5
2014-08-20
2012-05-25
John W
No

When Graph.addEdge(int s, int t) is called, it adds a row to the edge table, then sets the source and target node numbers in this row. When the row is created, the source and target node numbers default to 0. The table listener for this table is called, resulting in a call to Graph.updateDegrees(int e, int s, int t, int incr). However, this method is called while the source and target node numbers are still set to 0. If node 0 does not currently exist in the table (that is, the row was deleted), an exception is thown and the edge is not correctly added to the graph.

Adding extra row validity checks to Graph.updateDegrees(int e, int s, int t, int incr) seems to be one solution to this problem, but may not be the most efficient.

Discussion


Log in to post a comment.