Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

1 Answer 1

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.