2
$\begingroup$

I would like to label the vertices of a complete graph alphabetically.

But I am stuck because I don't know how to associate only one vertex to a letter.

y = {Before, After, Below, Above, Below, Above}

CompleteGraph[6, EdgeStyle -> {_ <-> 2 -> Red, Thickness[0.01]}, 
VertexSize -> 0.1, VertexLabels -> Placed[{"a", "b", "c", "d", "e", "f"}, y]]

enter image description here

I would appreciate any suggestion or help.

Thank you.

$\endgroup$

1 Answer 1

3
$\begingroup$
n = 6;  

c = CharacterRange["a", "z"][[;; n]];

labels = Table[i -> Style[c[[i]], 15, Bold], {i, n}];

CompleteGraph[n,
 EdgeStyle -> {_ <-> 2 -> Red, Thickness[0.01]}, 
 VertexSize -> 0.1,
 VertexLabels -> labels]

enter image description here

Update

Variable label placement

y = {Before, After, Below, Above, Below, Above};

labels = Table[i -> Placed[Style[c[[i]], 15, Bold], y[[i]]], {i, n}];

enter image description here

$\endgroup$
2
  • $\begingroup$ Thank you for your answer. I see now what I did wrong. But how can I change the position of the labels, e.x. "b" to be placed Before the vertex or "c" to be placed Below? Again, thank you. $\endgroup$
    – johnny09
    Nov 28, 2015 at 1:50
  • 1
    $\begingroup$ See updated answer $\endgroup$
    – eldo
    Nov 28, 2015 at 2:01

Your Answer

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

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