[jgrapht-users] Getting edges for a vertex
Brought to you by:
barak_naveh,
perfecthash
From: Santiago T. <sti...@gm...> - 2012-08-17 19:14:55
|
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 |