# How to label the Vertex and, or Edge labels with their weight

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?

-
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

## 1 Answer

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]


-
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 stackoverflow.com/q/7381085/353410 – belisarius has settled 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 youtube.com/watch?v=emAe6IClGys – belisarius has settled Feb 13 '13 at 22:44