Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

If I have already created a graph using Graph. Later, I want to add to the graph some vertex and/or edge labels, how can I do that?

Thank you.

share|improve this question

A random graph without any labeling:

g = RandomGraph[{11, 21}]

enter image description here

You can use SetProperty to add labeling P.S.

SetProperty[g, {EdgeLabels -> {3 \[UndirectedEdge] 4 -> "COOL"}, 
  VertexLabels -> {1 -> "STUFF"}}]

enter image description here

share|improve this answer
1  
actually in version 8.0.0.0, it is not working SetProperty[g, {EdgeLabels -> {3 \[UndirectedEdge] 4 -> "COOL"}, VertexLabels -> {1 -> "STUFF"}}]. Looks like SetProperty can only set one property at a time. – Qiang Li Feb 21 '12 at 22:26

Your Answer

 
discard

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.