Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I noticed that the Mathematica 9.0 documentation only mentions the usage of "Name" to label the vertexlabel or edgelabel in the Graph. Is there an option to use the Weights automatically just as "Name" does?

share|improve this question
Could you please split this into a separate question and answer to comply with the format of the site? It is okay to answer your own question. – Szabolcs Feb 13 '13 at 20:26
@Szabolcs Ok no problem. Is this ok? – Lou Feb 13 '13 at 20:35

I found that "EdgeWeight" and "VertexWeight" are next to "Name" also possible candidates.

Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 
  3 \[UndirectedEdge] 1}, VertexWeight -> {100, f[x], 300}, 
 EdgeWeight -> {10 || 20, Prime[x], g[x]^2}, 
 VertexLabels -> "VertexWeight", EdgeLabels -> "EdgeWeight", 
 ImagePadding -> 20]

Mathematica graphics

share|improve this answer
This was discussed in the mathgroup a year ago. Apparently this was documented in 8.0.0 and disappeared in later versions. – Sjoerd C. de Vries Feb 13 '13 at 21:51
@SjoerdC.deVries Yes that is correct. At that time this option however didn't work and got removed from the docs. Apparently it got fixed but the documentation was not updated. VertexWeight was also missing in the 8.0 docs. – Lou Feb 13 '13 at 22:08
@SjoerdC.deVries – Dr. belisarius Feb 13 '13 at 22:25
@belisarius Totally forgot that we had that discussion there as well. I checked that it doesn't work in 8.0.4, but it does in 9.0.1. – Sjoerd C. de Vries Feb 13 '13 at 22:29
@SjoerdC.deVries – Dr. belisarius Feb 13 '13 at 22:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.