Null values for SimpleGraph1

3 views
Skip to first unread message

David Argueta

unread,
Apr 27, 2012, 4:12:31 PM4/27/12
to cs31...@googlegroups.com
Is anyone else getting null values when running SimpleGraphTest? 
I have not added any code to the remove methods into SimpleGraph1. I just ran the test and the edges return as (null : null). Yet when SimpleGraph1 prints out it shows edges. I have included a snippet of my results followed by the full output. Are we suppose to modify addEdge?

J X 1
 edge = (null : null), source = J, target = X
class org.jgrapht.graph.SimpleGraph: ([A, B, X, Y, Z, C, J], [{A,B}, {B,X}, {X,Y}, {Y,Z}, {C,J}, {A,C}, {J,X}])
class cs310.SimpleGraph1: ([A, B, C, Y, X, J, Z], [{A,C}, {C,J}, {M,X}, {B,X}, {J,X}, {Y,Z}, {X,Y}, {A,B}])
vertex sets match
edge sets differ


A B 1
 edge = (A : B), source = A, target = B
B X 2
 edge = (B : X), source = B, target = X
X Y 2
 edge = (X : Y), source = X, target = Y
Y Z 1
 edge = (Y : Z), source = Y, target = Z
C J 3
 edge = (C : J), source = C, target = J
A C 2
 edge = (A : C), source = A, target = C
J X 1
 edge = (J : X), source = J, target = X
M X 2
 edge = (M : X), source = M, target = X
Graph: ([A, B, X, Y, Z, C, J, M], [{A,B}, {B,X}, {X,Y}, {Y,Z}, {C,J}, {A,C}, {J,X}, {M,X}])
A B 1
 edge = (null : null), source = A, target = B
B X 2
 edge = (null : null), source = B, target = X
X Y 2
 edge = (null : null), source = X, target = Y
Y Z 1
 edge = (null : null), source = Y, target = Z
C J 3
 edge = (null : null), source = C, target = J
A C 2
 edge = (null : null), source = A, target = C
J X 1
 edge = (null : null), source = J, target = X
M X 2
 edge = (null : null), source = M, target = X
Graph: ([A, B, C, M, Y, X, J, Z], [{A,C}, {C,J}, {M,X}, {B,X}, {J,X}, {Y,Z}, {X,Y}, {A,B}])
class org.jgrapht.graph.SimpleGraph: ([A, B, X, Y, Z, C, J], [{A,B}, {B,X}, {X,Y}, {Y,Z}, {C,J}, {A,C}, {J,X}])
class cs310.SimpleGraph1: ([A, B, C, Y, X, J, Z], [{A,C}, {C,J}, {M,X}, {B,X}, {J,X}, {Y,Z}, {X,Y}, {A,B}])
vertex sets match
edge sets differ

Betty O'Neil

unread,
Apr 27, 2012, 5:22:43 PM4/27/12
to David Argueta, cs31...@googlegroups.com
This is a case of toString() not being fully supported--toString for
an edge is not in the official API, yet LoadGraph calls it. To output a
String representation of an edge safely, LoadGraph should ask the graph
for its two vertices and use their toString's. OK, toString for vertex
is not in the official API either, but the vertex objects are much
more likely to have toString (I guess we should add that requirement.)

Anyway, just ignore this funny report by LoadGraph and don't expect
to be able to use toString with edges.--Betty O.

David Argueta

unread,
Apr 27, 2012, 7:21:40 PM4/27/12
to cs31...@googlegroups.com
Is it OK if I modify the DefaultEdge class in order to get this working properly?

Betty O'Neil

unread,
Apr 27, 2012, 8:26:24 PM4/27/12
to David Argueta, cs31...@googlegroups.com
Actually, it's not possible to edit DefaultEdge and fix this--the
user-supplied edge object in general doesn't know what vertices are
attached to it. edge's toString only works with DefaultEdge and the
jgrapht original graph sources because DefaultEdge extends their
IntrusiveEdge, which, like our InternalEdge, does know what vertices
are connected by it. So if you want to fix it, edit LoadGraph to
track down the vertices. But it's not necessary.
Reply all
Reply to author
Forward
0 new messages