RE: [jgrapht-developers] interface breaking changes
Brought to you by:
barak_naveh,
perfecthash
From: gu b. <bou...@ya...> - 2006-05-15 08:48:35
|
Hi, I agree with Barak about the three changes, specially the 1st point. By the way I will seize the opportunity of suggesting other changes. 1. AbstractBaseGraph ---------------------------- The constructor contains line : edgefactory.createEdge( new Object( ), new Object( ) ). That is to say all edge-factories must allow Object parameters, even if we wanted a factory that creates only edges whose vertices are of a specified type. Anyway if the edge factory is eliminated from the graph interface, as suggested by Barak, this problem will disappear. 2. Modifiable graph ---------------------------- Because the top-interface Graph contains add/remove methods (addVertex, removeVertex, addEdge, removeEdge), when creating an alternative implementation we must implement these modify-methods, although most graph-theory algorithms (at least those in JGraphT at the present time) do not need to modify the graph. Why not create a "ModifiableGraph" sub-interface of Graph (all modify-methods pushed down) ? It could be very easier for alternative implementations. 3. Dijkstra http://en.wikipedia.org/wiki/Dijkstra's_algorithm ---------------------------- The only constructor has a "raduis" argument. Why not create a second constructor without this argument ? Furthermore because Dijkstra algorithm computes the shortest paths between a starting vertex and each other vertex in a directed graph why not create a constructor with the star-vertex but without the end-vertex and pass the end- vertex argument to methods getLength(endVertex) and getPathEdgeList(endVertex) ? 4. ModifiableInteger ---------------------------- Why ModifiableInteger does not extend the java.lang.Integer class ? 5. Complexity ---------------------------- Generally the complexity of the methods are not mentioned. However it is very useful from an algorithmic point of view. For instance I have noticed that the dijkstra complexity is not mentioned as well as AbstractBaseGraph#degreeOf (which is O(#list), not O(1)). 6. DirEdge ---------------------------- What is the interest in discriminating between directed-edge and undirected-edge ? Is it not enough to consider that an edge is directed/undirected regarding a graph ? If the graph is a DirectedGraph, edges are directed, and otherwise edges are undirected. Anyway, at he present time for the graph classes in JGraphT, edges of a graph are either all directed or all undirected. 7. Graph#containsVertex ---------------------------- Two methods should be deleted in the Graph interface : Graph#containsEdge and Graph#containsVertex. They are redundant because of Graph#vertexSet().contains and Graph#edgeSet().contains. Best regards, Guillaume Barak Naveh <bar...@us...> a écrit : Since 0.7.0 will anyway involves some interface-breaking changes, it might be a good chance to consider fixing a few flaws were left lurking in Graph -- probably due my fault... 1. Edge factory ---------------------------- The inclusion of the edge factory was a pre-Java 5.0 attempt to provide some crude type-safety for edges. Now after generics have been applied, there seem to be no strong need for the edge factory. The Graph interface can be simplified by eliminating the edge factory. Consequently, addEdge(V,V) will become obsolete and could be eliminate as well. 2. NullPointerException -> IllegalArgumentException --------------------------------------------------- Some methods throw new NullPointerException. It might be better if they throw new IllegalArgumentException to avoid confusion with the NullPointerExceptions that the virtual machine may throw. See http://pmd.sf.net/rules/strictexception.html for more on that. 3. edgesOf(V v) ------------- Contract clarification: what if v is null? What if v doesn't exist in the graph? Probably should through IllegalArgumentException. Barak ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642 _______________________________________________ jgrapht-developers mailing list jgr...@li... https://lists.sourceforge.net/lists/listinfo/jgrapht-developers --------------------------------- Faites de Yahoo! votre page d'accueil sur le web pour retrouver directement vos services préférés : vérifiez vos nouveaux mails, lancez vos recherches et suivez l'actualité en temps réel. Cliquez ici. |