Re: [jgrapht-users] Bug in the induced subgraphs? (+Patch and JUnit test)
Brought to you by:
barak_naveh,
perfecthash
From: John S. <js...@gm...> - 2010-09-30 00:15:21
|
+jgrapht-users Thanks a lot for the clear explanation and unit test; I'm going to commit your fix to svn. It turned out not to be necessary to add the parentSubgraph data member because BaseGraphListener is already a non-static inner class. JVS On Wed, Sep 29, 2010 at 12:13 PM, Michele Mancioppi <mic...@gm...> wrote: > Dear John, > > I think I have stepped into a bug affecting induced subgraphs in jGraphT. > > The problem is the following: I create a listenable graph, and then an induced subgraph based on it (by passing a set of vertexes and null set of edges to the subgraph's constructor). If I add an edge to the base graph and not both its vertexes also in the subgraph, the BaseListenerGraph of attached by the subgraph to the base graph generates an IllegalArgumentException because of the failures in one of the invocations of 'assertVertexExists' in the method . > > I believe it is a bug. An induced subgraph should always contain all and only the edges of the base graph whose source and target are both in the subgraph. Attached you find a patch that solves the problem and a JUnit test case for regression testing. Unfortunately I did not have the opportunity of running the JUnit tests, but it is a pretty straightforward modification. I did not change the serialVersionUID of the class Subgraph as I don't know what is your policy about it. > > Of course, the code submitted in the attached patch and the JUnit test case are licensed under the LGPL, so feel free to apply it to the the jGraphT codebase :-) > > Cheers, > Michele Mancioppi > |