Thread: [jgrapht-users] DepthFirstIterator - Skip and move to next branch?
Brought to you by:
barak_naveh,
perfecthash
From: Michael Z. <li...@in...> - 2008-03-03 12:17:57
|
Hi there! for a project I use jgrapht as library to store information about parent-child relationships. Thanks a lot for this great library! One issue I could not solve myself is related to DepthFirstIteration. Assume the following graph: A->B->C-D->E A->X->Y->Z I want to iterate over all items in my graph depth first. If a certain condition is true, the rest of the current branch should be skipped and the iterator should continue with the next branch. In my example, the iterator would go as follows: 1) A->X->Y (condition fulfilled; skip Z) 2) B->C->D->E Is there an easy way how to solve this? Any option like: DepthFirstIterator it = new ... while (it.hasNext()) { MyObject o = it.next(); if (o.condition == true) it.nextBranch() thanks and cu, Michael |
From: John V. S. <js...@gm...> - 2008-03-07 05:57:23
|
For a tree, the semantics are unambiguous. But what about a DAG? JVS Michael Zimmermann wrote: > Hi there! > > for a project I use jgrapht as library to store information about > parent-child relationships. Thanks a lot for this great library! > > One issue I could not solve myself is related to DepthFirstIteration. > > Assume the following graph: > A->B->C-D->E > A->X->Y->Z > > I want to iterate over all items in my graph depth first. If a certain > condition is true, the rest of the current branch should be skipped and > the iterator should continue with the next branch. > > In my example, the iterator would go as follows: > 1) A->X->Y (condition fulfilled; skip Z) > 2) B->C->D->E > > Is there an easy way how to solve this? Any option like: > > DepthFirstIterator it = new ... > while (it.hasNext()) { > MyObject o = it.next(); > if (o.condition == true) > it.nextBranch() > > > thanks and cu, Michael > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > jgrapht-users mailing list > jgr...@li... > https://lists.sourceforge.net/lists/listinfo/jgrapht-users > |
From: Michael Z. <li...@in...> - 2008-03-11 15:41:22
|
John V. Sichi wrote: > For a tree, the semantics are unambiguous. But what about a DAG? DAG = directed graph? If so, you are right. For anything more complex than a tree, "sub"-elements can not be determined reliably. Yet, any other ideas how to do this with jgrapht? Currently, here I do use some recursive function calls with "for each child: call recursively). Pretty ugly. cu, Michael |
From: Agile A. <agi...@gm...> - 2008-03-21 02:19:26
|
Hi - would some point me to an archive file containing the the source code for the examples on http://jgrapht.wikispaces.com When I right click on these links, I end up downloading the copies of the web pages. Also, displaying Java source code in black type on a gray background should be strongly discouraged simply because it's optimized for low contrast. In addition, it would be extremely helpful to new comers if these examples were included the distribution file in an examples directory. Thank you! -- Article. VI. Clause 3 of the constitution of the United States states: "The Senators and Representatives before mentioned, and the Members of the several State Legislatures, and all executive and judicial Officers, both of the United States and of the several States, shall be bound by Oath or Affirmation, to support this Constitution; but no religious Test shall ever be required as a Qualification to any Office or public Trust under the United States." |
From: John V. S. <js...@gm...> - 2008-03-21 07:34:29
|
Agile Aspect wrote: > Hi - would some point me to an archive file containing the > the source code for the examples on > > http://jgrapht.wikispaces.com > > When I right click on these links, I end up downloading the copies > of the web pages. The examples are intended to be short snippets so that you can use copy and paste if you actually want to compile them. But mainly they are there just for browsing example usage patterns, which is why we don't redundantly maintain them in the distribution. Of course, that means they may break occasionally with new versions, but the nice part about wiki is that anyone can fix them :) > Also, displaying Java source code in black type on a gray background > should be strongly discouraged simply because it's optimized for low > contrast. These are using the default Java colorization provided by wikispaces, so you might want to send in your feedback here: http://www.wikispaces.com/help+index (BTW, I agree with you.) JVS |