GraphStream Users

Archives de la liste Aide

Question about the unoriented edges

Chronologique Discussions 
  • From: guilhelm savin <guilhelm.savin AT>
  • To: users AT
  • Subject: Question about the unoriented edges
  • Date: Thu, 9 Jun 2011 16:27:54 +0200
  • Domainkey-signature: a=rsa-sha1; c=nofws;; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=q2+t2DGHGSqkxRfy2Nkn44leEAt2U3kTb+T0Co1f2UrjaosmgOAwPrzFl/9BhFA8v9 LYBQnY3uu5FVs6wS5n+zxkqbZ8psNMDVxTHJlieWFC28Lse0RJpCvbje4hDus1sB/Ehi d/MQWCF48aOPJ2ZSf8Vr5o5EQ8aznuvgx7Byk=

From NicolasSys:

I try to find the shortest path with the algorithm APSP on a simple graph composed by 3 nodes and
2 unorientend edges.

Here is my code :

public class BugEdgeNonOriented {

static Graph g;

public static void main(String args[]) {
new BugEdgeNonOriented();
shortestPath(g, "A", "C");

public BugEdgeNonOriented() {
g = new SingleGraph("test");

g.addEdge("AB", "A", "B");
g.addEdge("BC", "C", "B");
for (Node node : g) {
node.addAttribute("ui.label", node.getId());

private static void shortestPath(Graph g, String source, String dest) {
APSP apsp = new APSP();
APSPInfo info = g.getNode(source).getAttribute(APSPInfo.ATTRIBUTE_NAME);
Path p = info.getShortestPathTo(dest);
// Print
System.out.println("Path's lenght : " + p.size());
System.out.println("Path : " + p);
Iterator<Edge> ie = p.getEdgePath().iterator();
while (ie.hasNext()) {
Edge e =;
System.out.println("Edge's end node : " + e.getNode1());
And here are the results displayed in the console and the generated graph :


Is this a normal functioning ? Because it does not allow to display a shortest paths nodes for example. I can do
it differently (by using a multigraph and insert 2 edges between the 2 nodes) but I didnt managed to do it this way
and I am simply wondering if thats normal ?
Its like if the edges are oriented by the way we construct them or maybe I did not use the option getnode0() and
getnode1 properly but I can't know when to use one or the other since I just want to follow the generated path
I found and display some of its informations.


Archives gérées par MHonArc 2.6.16.

Top of page