# Associate vertex coordinates and labels

This sounds easy (in which case I will delete my question) and maybe I am getting a bit tired, but I can't find an easy way to create a list from an automatically-generated graph where vertices labels and coordinates are associated, e.g. {index_vertex, {x,y}}.

From this image...

...here is my code so far:

image = Import["https://i.stack.imgur.com/5ZNrE.png"];
mask = FillingTransform[Thinning[Binarize[ColorReplace[image, White -> Black, .055], 0]], CornerNeighbors -> True];
morphograph = MorphologicalGraph[skel, VertexSize -> 2, VertexLabels -> "Index"];
newtreegraph = TreeGraph[DeleteCases[EdgeList[morphograph], x_ [UndirectedEdge] x_], VertexCoordinates -> GraphEmbedding[morphograph], VertexSize -> 5, VertexLabels -> "Index"]


that generates this nice TreeGraph

From that, I can obtain the EdgeList and vertices coordinates via GraphEmbedding but cannot easily connect the two... There must be an easy way I can't find ... Thanks

Do you mean this?

AssociationThread[
VertexList[newtreegraph],
PropertyValue[newtreegraph, VertexCoordinates]
]


<|1 -> {677.5, 957.5}, 8 -> {677.5, 953.5}, <<459>>, 455 -> {300.5, 84.5}|>

• Instead of PropertyValue[newtreegraph, VertexCoordinates] you can also use GraphEmbedding[newtreegraph]. – Szabolcs Feb 21 '19 at 16:29
• Yes thanks! That was indeed pretty easy... – Valacar Feb 21 '19 at 21:28
• You're welcome! Might seem easy (afterwards), but this was also a question worthwhile to ask (+1). – Henrik Schumacher Feb 21 '19 at 21:30