Message Boards Message Boards

0
|
2616 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

PropertyValue[{g,e}, EdgeWeight] doesn't work?

Posted 10 years ago

I've run into what looks like a bug in PropertyValue: it doesn't seem to be able to retrieve EdgeWeight's. For instance:

p0 = Graph[{Property["root" [DirectedEdge] 1, EdgeWeight -> 2.0]}, VertexLabels -> "Name"]; p0 // InputForm

Graph[{"root", 1}, {DirectedEdge["root", 1]}, {Properties -> {DirectedEdge["root", 1] -> {EdgeWeight -> 2.}}, VertexLabels -> {"Name"}}]

PropertyValue[{p0, "root" [DirectedEdge] 1}, EdgeWeight]

"$"Failed

There is also an example on the PropertyValue documentation of trying to do this, and it also shows the result "$"Failed, right there in the doco! Perhaps related, GraphDistance[p0, "root", 1], which ought to return 2.0, returns instead 1.0.

Attachments:
POSTED BY: Leon Avery
2 Replies

A correction is in the works for a future release.

If someone finds a work around, please feel free to post it.

POSTED BY: Bruce Miller
Posted 10 years ago

Workaround, sort of: Some things, such as GraphDistance, seem to work correctly if the EdgeWeight property of the Graph is set to the list of weights. This is still painful, however, as graph manipulation functions such as EdgeAdd, EdgeDelete, and GraphUnion throw this property away. At present I have rolled my own edgeAdd and edgeDelete functions.

POSTED BY: Leon Avery
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract