We can verify this with a Euler tour of our 15 trees using DepthFirstScan[]
, which will recover the stirling permutations:
ggg = {{{0 \[UndirectedEdge] 1, 1}, {0 \[UndirectedEdge] 2,
2}, {0 \[UndirectedEdge] 3, 3}}, {{0 \[UndirectedEdge] 1,
1}, {0 \[UndirectedEdge] 3, 3}, {0 \[UndirectedEdge] 2,
2}}, {{0 \[UndirectedEdge] 3, 3}, {0 \[UndirectedEdge] 1,
1}, {0 \[UndirectedEdge] 2, 2}}, {{0 \[UndirectedEdge] 1,
1}, {0 \[UndirectedEdge] 2, 2}, {1 \[UndirectedEdge] 3,
3}}, {{0 \[UndirectedEdge] 1, 1}, {0 \[UndirectedEdge] 2,
2}, {2 \[UndirectedEdge] 3, 3}},
{{0 \[UndirectedEdge] 2, 2}, {0 \[UndirectedEdge] 1,
1}, {0 \[UndirectedEdge] 3, 3}}, {{0 \[UndirectedEdge] 2,
2}, {0 \[UndirectedEdge] 3, 3}, {0 \[UndirectedEdge] 1,
1}}, {{0 \[UndirectedEdge] 3, 3}, {0 \[UndirectedEdge] 2,
2}, {0 \[UndirectedEdge] 1, 1}}, {{0 \[UndirectedEdge] 2,
2}, {0 \[UndirectedEdge] 1, 1}, {1 \[UndirectedEdge] 3,
3}}, {{0 \[UndirectedEdge] 2, 2}, {0 \[UndirectedEdge] 1,
1}, {2 \[UndirectedEdge] 3, 3}},
{{0 \[UndirectedEdge] 1, 1}, {1 \[UndirectedEdge] 2,
2}, {0 \[UndirectedEdge] 3, 3}}, {{0 \[UndirectedEdge] 3,
3}, {0 \[UndirectedEdge] 1, 1}, {1 \[UndirectedEdge] 2,
2}}, {{0 \[UndirectedEdge] 1, 1}, {1 \[UndirectedEdge] 3,
3}, {1 \[UndirectedEdge] 2, 2}}, {{0 \[UndirectedEdge] 1,
1}, {1 \[UndirectedEdge] 2, 2}, {1 \[UndirectedEdge] 3,
3}}, {{0 \[UndirectedEdge] 1, 1}, {1 \[UndirectedEdge] 2,
2}, {2 \[UndirectedEdge] 3, 3}}};
ggg2 = ggg /. {a_ \[UndirectedEdge] b_, c_} :>
Labeled[a \[UndirectedEdge] b, c];
list = {};
Map[DepthFirstScan[#,
0, {"PrevisitVertex" -> (If[# != 0, AppendTo[list, #],
AppendTo[list, "\n"]] &),
"PostvisitVertex" -> (If[# != 0, AppendTo[list, #],
AppendTo[list, " "]] &)}] &, ggg2];
Row[list]