How to Label Graph Edges with their weights

前端 未结 4 1066
萌比男神i
萌比男神i 2021-02-09 11:57

Warning! I posted the question when Mathematica v 8.0 was the coolest kid. The bug has been solved as of version 9.0.1

The help for EdgeLabels states:

4条回答
  •  遥遥无期
    2021-02-09 12:49

    EdgeLabels works fine. EdgeWeights does not.

    It may already be obvious from Belisarius' second example that the problem lies with EdgeWeights not EdgeLabels

    Here's some additional evidence. EdgeLabels very gladly displays a variety of labels correctly. But when you ask mma to display "EdgeWeights", it incorrectly displays 1's, no matter what you've stored there.

    CompleteGraph[4, VertexShapeFunction -> "Name",
     EdgeLabels -> {
       UndirectedEdge[1, 2] -> "hello", 
       UndirectedEdge[1, 4] -> "goodbye", UndirectedEdge[2, 3] -> 55, 
       UndirectedEdge[3, 4] -> \[Pi]/2, 
       UndirectedEdge[4, 2] -> 
       "\!\(\*UnderoverscriptBox[\(\[Sum]\), \(i = 0\), \(26\)]\)(-1\!\(\
       \*SuperscriptBox[\()\), \(i\)]\)\!\(\*SuperscriptBox[\(\[Theta]\), \
       \(n - i\)]\)", UndirectedEdge[1, 3] -> {a, b, c}}]
    

    EdgeWeights.png

    The bug is not unique to CompleteGraph. Graph and GridGraph have the same problem.

提交回复
热议问题