From: Rui C. <cha...@ho...> - 2012-10-02 22:21:56
|
Hi Ernst, Thanks for your reply. Glad to know at least that create a new CycleDetector object should work by definition. Regarding to a bug in my code or with JGrapht, I am not sure...but I do noticed some weird behavior of this DefaultDirectedGraph, that if I add edge as graph.addEdge("parent","child"), then the resulting graph contains always the last edge added to the graph (some overwritting is going on), if I use graph.addEdge("parent","child","ei") (i=iteration index), then all edges are corrected added... I don't know if this is propagating into the CycleDetector bug because I modify the graph in a loop and if the graph does not add the edge correct, it may result in a bug seemingly at the CycleDetector's end. Ray To: cha...@ho...; jgr...@li... From: hnr...@gr... Subject: Re: [jgrapht-users] A question to cycle detection using DefaultDirectedGraph Date: Tue, 2 Oct 2012 21:54:13 +0200 Hello Ray, this phrase means that you cannot modify the graph specified when creating the CycleDetector and expect the CycleDetector to work correctly. Instead, you should create a new CycleDetector after every modification to the graph, and use this new CycleDetector. Since this is what you say you do, I guess there is a bug in your code, or a bug in CycleDetector or a mistake is made when manually checking for cycles. Try to find a minimal example of the problem. Regards, Ernst -- Information System on Graph Classes and their Inclusions (ISGCI) http://www.graphclasses.org ----- Reply message ----- From: "Rui Chang" <cha...@ho...> To: <jgr...@li...> Subject: [jgrapht-users] A question to cycle detection using DefaultDirectedGraph Date: Sun, Sep 30, 2012 19:07 Hi All, I am new to JGraphT. I want to use CycleDetector to detect cycles in a DefaultDirectedGraph. In my code, the graph is initialized/constructed at the beginning of the program, then I have a loop, in each of which, the graph is modified by calling addEdge and/or removeEdge randomly. But the total vertex set stay the same. In each loop, after modification on graph, I initiate a new CycleDetector class to detect cycles in the modified graph, but sometimes, I see obviously there are cycles in the modified graph, which is not captured by CycleDetector! I wonder is it some bug or is it my mistake to use CycleDetector in this way as I recall the javadoc of CycleDetector class says something like: "The inspected graph is specified at construction time and cannot be modified"... But I don't know if I really understand what it means... Thanks for any thought!Best,Ray |