3
$\begingroup$

I find VertexLabels -> "Name" a strange setting to achieve graph nodes labeled by their index: Graph[edges, VertexLabels -> "Name"]. What is the logic behind this option value?


FieldGraphZ18


$\endgroup$
4
  • $\begingroup$ Would you prefer the plural seen here, Plot[{x, x^2}, {x, 0, 10}, PlotLegends -> "Expressions"] ? $\endgroup$ Commented Apr 22, 2015 at 11:47
  • $\begingroup$ @MartinJohnHadley: I just find "Name" an odd way to specify that option. Not singular vs. plural, but just why "Name" rather than something more descriptive, such as "ByIndex". $\endgroup$ Commented Apr 22, 2015 at 11:49
  • 1
    $\begingroup$ @joseph-orourke if "ByIndex" was available I'd assume it would give me the index of each vertex, whereas "Name" gives the value (?) of the vertex. So if the vertices are images then "Name" will show the image, which I think is desirable. IMO it should be plural, mess up everytime on that. $\endgroup$ Commented Apr 22, 2015 at 11:57
  • $\begingroup$ @MartinJohnHadley: I see. Did not think (or know) that nodes could be images. Thanks. $\endgroup$ Commented Apr 22, 2015 at 11:59

1 Answer 1

3
$\begingroup$

Expanding on comment, the VertexLables->"Name" option shows the "value" of each vertex:

{a, b, c} = {ExampleData[RandomChoice[ExampleData["TestImage"]]], 1, "c vertex"}

enter image description here

Note the use of ImagePadding to ensure the VertexLabels are not clipped.

Graph[{a <-> b, b <-> c, c <-> a}, VertexLabels -> "Name", ImagePadding -> 10]

enter image description here

Opinion

I find it confusing that "Name" is used rather than the plural, but this is nothing compared to the requirement to tinker with ImagePadding when using this option.

$\endgroup$

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.