# How to label name for a graph?

I'd like to label a name $$K_4$$ in following graph. How to do that?

completegraph4 = ImportString["C~", "Graph6"]


• Graph[completegraph4, PlotLabel -> Style["K_4", 16]]?
– kglr
Apr 15, 2020 at 9:00
• ... or Labeled[completegraph4, Style["K_4", 16], Top]?
– kglr
Apr 15, 2020 at 9:01
• Thanks! I'd like to ask more, How to adjust the position of label ? Apr 15, 2020 at 9:07
• I'm wondering: Did the OP even look at the documentation for Graph which answers all this? Apr 15, 2020 at 17:42

All Graphics options work in Graph. You can use PlotLabel or add a Text primitive to the Epilog.

label = Style["\!$$\*SubscriptBox[\(K$$, $$4$$]\)", 16]

CompleteGraph[4, PlotLabel -> label]

CompleteGraph[4, Epilog -> Text[label, Scaled[{0.8, 0.8}]]]


You could also use Labeled.

If you want to place the label at the top you can use the option PlotLabel:

Graph[completegraph4, PlotLabel -> Style["K_4", 16]]


Or wrap the graph object with Labeled:

Labeled[completegraph4, Style["K_4", 16], Top]


Labeled[completegraph4, Style["K_4", 16], Right]


To get a finer control on label position you can use Legended + Placed:

Legended[completegraph4, Placed[Style["K_4", 16], {.8, .9}]]


You can also use Locator to place the label interactively:

DynamicModule[{loc = {.8, .8}},
Dynamic @ Show[Graph[completegraph4], Graphics[{Locator[loc, Style["K_4", 16]]}]]]


or

DynamicModule[{loc = {.8, .8}},
Graph[completegraph4, Epilog -> {Dynamic@Locator[loc, Style["K_4", 16]]}]]


• haha, Magical mma! Apr 15, 2020 at 10:15