Hi Nick,

Could it be possible that the same iterator is being used for multiple
traversals. It maintains state internally so if it were say reused for a
second call it would not return any graph objects since they have already
been marked as "seen".

Other then that the only thing I can think of is the graph itself... is it
directed?

If all else fails and you can write a test case that reproduces the problem
we can look at it.

-Justin

On Thu, Aug 11, 2011 at 5:34 AM, Nick Malleson <[email protected]>wrote:

> Hi,
>
> I'm having a problem with a graph traversal and I was wondering if anyone
> has some suggestions.
>
> What I want to do is quite simple: given an origin edge in a graph, I want
> to create a sub-graph around the origin containing N edges. To do this I
> have created a visitor (called SubGraphVisitor) which counts and records
> the
> number of graph components it has visitted. It termines once it has
> visitted
> N componets and can be used to create a subgraph from the components it has
> seen.
>
> The problem is that sometimes it doesn't work, the 'visit' method of my
> SubGraphVisitor isn't called and so no sub-graph is created. I have checked
> that paths can be created from the edge so I think the graph is correct. I
> have also checked that the graph is complete.
>
> Here is the code that does the walking:
>
> SubGraphVisitor graphVisitor = new SubGraphVisitor(); // This is my visitor
> BreadthFirstIterator iterator = new BreadthFirstIterator();
> BasicGraphTraversal bgt = new BasicGraphTraversal(
>        this.graph,
>        new SimpleGraphWalker(graphVisitor),
>        iterator);
> iterator.setSource(edge1);
> bgt.traverse();
> Graph subGraph = graphVisitor.getSubGraph(); // Sometimes the graph is
> empty
>
> Can anyone sugggest why the call to traverse() doesn't lead to my visitor's
> visit() method being called? I've had a look through the source code for
> BasicGraphTraversal it looks as if the iterator isn't returning a
> component,
> but I'm not sure why this might be.
>
> Thanks for your help,
> Nick
>
> P.S.
> Thanks for all the work that has gone into gt-graph and geotools in
> general,
> it's invaluable for my work.
>
> --
> View this message in context:
> http://osgeo-org.1803224.n2.nabble.com/Problem-iterating-over-a-graph-tp6676019p6676019.html
> Sent from the geotools-gt2-users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
> user administration capabilities and model configuration. Take
> the hassle out of deploying and managing Subversion and the
> tools developers use with it.
> http://p.sf.net/sfu/wandisco-dev2dev
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>



-- 
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.
------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. 
http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to