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.


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

  • 1
    $\begingroup$ actually in version, 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. $\endgroup$
    – Qiang Li
    Feb 21, 2012 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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