From: Konstantin_R <rub...@us...> - 2012-08-17 09:05:59
|
Hello jgrapht! I tried to ask this question at https://github.com/jgrapht/jgrapht/issues , but maybe it was the wrong place for it. Could you please help me with the following? I think I came across a bug that affects a general graph behavior. When using ListenableDirectedGraph one can add a listener using method 'addGraphListener()'. When using DirectedNeighborIndex a listenable graph should be passed in the DirectedNeighborIndex's contructor as a parameter. According to the DirectedNeighborIndex's spec "If it [DirectedNeighborIndex] is added as a listener to a graph other than the one it indexes, results are undefined." Does it mean that the behavior of the DirectedNeighborIndex becomes undefined or also the behavior of the graphs concerned as well? I suppose, that graphs concerned shouldn't be affected in this situation. Is it true? In reality the behavior of graph changes and java.lang.IllegalArgumentException is thrown at org.jgrapht.graph.AbstractGraph.assertVertexExist() when trying to add a new edge in the graph. The following JUnit test highlights the problem: public void testListenableDirectedGraph() throws Exception { ListenableDirectedGraph<String, DefaultEdge> listenDG = new ListenableDirectedGraph<String, DefaultEdge>( DefaultEdge.class); String vertex1 = "v1"; listenDG.addVertex(vertex1); String vertex2 = "v2"; listenDG.addVertex(vertex2); listenDG.addEdge(vertex1, vertex2); ListenableDirectedGraph<String, DefaultEdge> listenDG2 = new ListenableDirectedGraph<String, DefaultEdge>( DefaultEdge.class); DirectedNeighborIndex<String, DefaultEdge> dni = new DirectedNeighborIndex<String, DefaultEdge>( listenDG2); listenDG.addGraphListener(dni); String vertex3 = "v3"; listenDG.addVertex(vertex3); listenDG.addEdge(vertex3, vertex1); // throws IllegalArgumentException exception } In the jgrapht mailing list there's a bug which looks related, although I cannot be sure: http://jgrapht-users.107614.n3.nabble.com/Re-Bug-in-the-induced-subgraphs-Patch-and-JUnit-test-td1605888.html Could you please confirm if this is a problem? As a possible solution, is it possible to have a check in the 'addGraphListener()' to avoid such behavior? Thanks, Konstantin -- View this message in context: http://jgrapht-users.107614.n3.nabble.com/DirectedNeighborIndex-ListenableDirectedGraph-bug-tp4024720.html Sent from the jgrapht-users mailing list archive at Nabble.com. |