From: Santiago T. <sti...@gm...> - 2012-08-17 22:34:44
|
Thank you Ernst, I am extending DefaultEdge, but not overloading any method. Now it works fine! Santi 2012/8/17 hnr...@gr... <hnr...@gr...> > Hi, > > edge.getTarget() is protected. Are you overloading? > > For general purposes use graph.getEdgeTarget(edge). jgrapht stores the > structure in the graph, not in the vertices/edges. This makes it possible > to use an arbitrary object as a vertex/edge in multiple graphs. > > Ernst > > -- > Information System on Graph Classes and their Inclusions (ISGCI) > http://www.graphclasses.org > > > ----- Reply message ----- > From: "Santiago Timón" <sti...@gm...> > To: <jgr...@li...> > Subject: [jgrapht-users] Getting edges for a vertex > Date: Fri, Aug 17, 2012 21:14 > > > Hi, > > I'm pretty newbie with JGraphT and the first thing I tried went bad. I > must say the API is very straightforward, but it seems it behaves different > from what I expect. > > The simple example: > > DirectedMultigraph<String, DefaultEdge> graph = newDirectedMultigraph<String, DefaultEdge>(DefaultEdge. > class); > > String a = "a"; > > String b = "b"; > > graph.addVertex(a); > > graph.addVertex(b); > > graph.addEdge(a, b); > > for (DefaultEdge edge : graph.edgesOf(a)) { > > String target = (String) edge.getTarget(); > > System.out.println(target); > } > > I am working on a much more complex problem, but this simple code doesn't > work as I thought. I don't know why the edges doesn't store the source and > target vertex but null. > > It's very important to me to travel through the graph investigating > vertex's edges, can anybody tell me how to do it? > > Many Thanks, > > Santi > |