1
$\begingroup$

I have a graph that I generated using upper half-plane. The graph will become bigger as I increase the iteration. For example, at first iteration, this is the graph that is generated. First iteration

And this is the graph generated at tenth iteration. 10th iteration

So, my question is how can I denote all the vertex in the graph in integer form? I have try using Show[SetProperty[G, VertexLabels -> "Name"], PlotRange -> All] . vertexlabels

I have also used the replace method by replacing the vertex coordinates to an integer. But I can only do that if the graph size is small. What can I do if the graph size is large?

$\endgroup$
2
$\begingroup$

Use IndexGraph.

Example:

g = NearestNeighborGraph[RandomReal[1, {10, 2}], VertexLabels -> "Name"]

enter image description here

IndexGraph[g]

enter image description here


If you only want to change how the vertices are labelled in the visualization, but you do not want to change the names that you use to refer to them in your program, then simply use the option

VertexLabels -> "Index"
$\endgroup$
  • $\begingroup$ It works! Thank you so much @Szabolcs. $\endgroup$ – nasha amalina Feb 19 '18 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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