Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Jack Gibson <jagbson@ya...>  20130225 00:18:15

Hi, To illustrate the issue I create a graph that looks as follows (F is the root): F > A > B > C > D > E Now when I traverse with BreadthFirstIterator I get following representation. Note that the result is not sorted correctly as the root is A and not F!! Vertex A Edge A > B Vertex B Edge B > C Vertex C Edge C > D Vertex D Edge D > E Vertex E Vertex F Edge F > A Here is the code that I used: public class BreathFirstSearchTest { public static void main(String [ ] args) { DirectedGraph<String, DefaultEdge> g = new DefaultDirectedGraph<String, DefaultEdge>(DefaultEdge.class); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); g.addVertex("D"); g.addVertex("E"); g.addVertex("F"); // F > A > B > C > D > E g.addEdge("A", "B"); g.addEdge("B", "C"); g.addEdge("C", "D"); g.addEdge("D", "E"); g.addEdge("F", "A"); BreadthFirstIterator<String, DefaultEdge> i = new BreadthFirstIterator<String, DefaultEdge>(g); while (i.hasNext()) { String node = i.next(); Set<DefaultEdge> edgeList = g.outgoingEdgesOf(node); System.out.println("Vertex " + node); for (DefaultEdge edge : edgeList) { System.out.println(" Edge " + g.getEdgeSource(edge) + " > " + g.getEdgeTarget(edge)); } } } } 
From: H.N. de Ridder <hnridder@gr...>  20130225 08:48:25

On Sun, Feb 24, 2013 at 04:16:43PM 0800, Jack Gibson wrote: Hi Jack, > To illustrate the issue I create a graph that looks as follows (F is the root): > > F > A > B > C > D > E > > Now when I traverse with BreadthFirstIterator I get following representation. Note that the result is not sorted correctly as the root is A and not F!! > > Vertex A > Edge A > B > Vertex B > Edge B > C > Vertex C > Edge C > D > Vertex D > Edge D > E > Vertex E > Vertex F > Edge F > A This is not an error. If you don't specify the start vertex, the BreadthFirstIterator starts at an arbitrary vertex. Once it has visited all vertices reachable from there, it will pick an arbitrary unvisited vertex and start from there. So your code could also have traversed as: D>E>F; B>C; A If you have sources in your graph and want to do a BFS from them, you'll have to find them yourself and start BFS from there. Note that in this case the iterator will not restart itself once it has visited all vertices reachable from the provided start vertex. Regards, Ernst  Information System on Graph Classes and their Inclusions (ISGCI) http://www.graphclasses.org 
From: H.N. de Ridder <hnridder@gr...>  20130225 09:23:24

On Mon, Feb 25, 2013 at 09:21:55AM +0100, H.N. de Ridder wrote: Sorry, that example should read C>D>E; A>B; F Ernst > On Sun, Feb 24, 2013 at 04:16:43PM 0800, Jack Gibson wrote: > > Hi Jack, > > > To illustrate the issue I create a graph that looks as follows (F is the root): > > > > F > A > B > C > D > E > > > > Now when I traverse with BreadthFirstIterator I get following representation. Note that the result is not sorted correctly as the root is A and not F!! > > > > Vertex A > > Edge A > B > > Vertex B > > Edge B > C > > Vertex C > > Edge C > D > > Vertex D > > Edge D > E > > Vertex E > > Vertex F > > Edge F > A > > This is not an error. If you don't specify the start vertex, the > BreadthFirstIterator starts at an arbitrary vertex. Once it has visited all > vertices reachable from there, it will pick an arbitrary unvisited vertex > and start from there. > > So your code could also have traversed as: > D>E>F; B>C; A > > If you have sources in your graph and want to do a BFS from them, you'll > have to find them yourself and start BFS from there. Note that in this case > the iterator will not restart itself once it has visited all vertices > reachable from the provided start vertex. > > Regards, > Ernst > >  > Information System on Graph Classes and their Inclusions (ISGCI) > http://www.graphclasses.org > >  > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_feb > _______________________________________________ > jgraphtusers mailing list > jgraphtusers@... > https://lists.sourceforge.net/lists/listinfo/jgraphtusers >  Information System on Graph Classes and their Inclusions (ISGCI) http://www.graphclasses.org 