Re: [jgrapht-users] DepthFirstIterator - Skip and move to next branch?
Brought to you by:
barak_naveh,
perfecthash
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 > |