0

Here is my code:

g = new SparseMultigraph<String, Double>();

g.addVertex("A");
g.addVertex("B");
g.addVertex("C"); 

g.addEdge(0.5, "A", "B"); 
g.addEdge(0.5, "B", "C"); 
g.addEdge(0.3, "A", "C"); 

System.out.println("The graph g = " + g.toString()); 

When I run I have this error:

edge 0.5 already exists in this graph with endpoints <A, B> and cannot be added with endpoints <B, C>

Is it possible to have two arcs with the same weight?

double-beep
  • 5,031
  • 17
  • 33
  • 41
  • I found the solution to my problem with this code : http://www.grotto-networking.com/JUNG/BasicDirectedGraph.java – user3609210 Jun 01 '14 at 11:26

1 Answers1

0

Fundamentally, the problem is that you're trying to treat an edge weight--which may not be unique--as a unique handle for an edge.

The section on User Data in this manual outlines various options for associating data with graph elements (edges and nodes): http://sourceforge.net/apps/trac/jung/wiki/JUNGManual

Joshua O'Madadhain
  • 2,704
  • 1
  • 14
  • 18