How do I "read out" the vertex names on this graph?
You could use DepthFirstScan
:
Choose the starting vertex:
svertex = Cases[VertexList[g], x_ /; VertexDegree[g, x] == 1]
{9, 33}
Extract the order of vertices:
Reap[DepthFirstScan[g,
svertex[[1]], {"PrevisitVertex" -> Sow}];][[2, 1]]
{9, 10, 1, 2, 4, 3, 8, 7, 6, 5, 24, 23, 25, 26, 29, 30, 37, 38, 39, 40, 43, 44, 35, 36, 31, 32, 27, 28, 21, 22, 17, 18, 14, 13, 15, 16, 12, 11, 20, 19, 42, 41, 34, 33}
We can use GraphPeriphery
to get the start and endpoints, and then use these in FindPath
:
periphery = GraphPeriphery[g]
FindPath[g, ##]& @@ periphery
{9,33}
{{9,10,1,2,4,3,8,7,6,5,24,23,25,26,29,30,37,38,39,40,43,44,35,36,31,32,27,28,21,22,17,18,14,13,15,16,12,11,20,19,42,41,34,33}}
If g
is the graph from the OP, then you can do this in versions 9 through 11
combGrData = {EdgeRules@g,
GraphEmbedding@g} /. {{a_Real, b_Real} :> {{a, b}},
HoldPattern@Rule[a__] :> {{a}}};
<< Combinatorica`
Graph @@ combGrData // HamiltonianPath
(* {9, 10, 1, 2, 4, 3, 8, 7, 6, 5, 24, 23, 25, 26, 29, 30, 37, 38, 39,
40, 43, 44, 35, 36, 31, 32, 27, 28, 21, 22, 17, 18, 14, 13, 15, 16,
12, 11, 20, 19, 42, 41, 34, 33}
If someone can explain the SetDelayed
error I get in version 11 I'd be much abliged.