I would like to map every vertex of my TreeGraph to an List.
g=TreeGraph[{1, 2, 3, 4, 5}, {1 \[DirectedEdge] 2, 1 \[DirectedEdge] 3,
1 \[DirectedEdge] 4, 1 \[DirectedEdge] 5},
VertexWeight -> {{1}, {4}, {9}, {16}, {25}}]
It seems that g is not a valid graph whereas the next one is valid
gg=TreeGraph[{1, 2, 3, 4, 5}, {1 \[DirectedEdge] 2, 1 \[DirectedEdge] 3,
1 \[DirectedEdge] 4, 1 \[DirectedEdge] 5},
VertexWeight -> {1, 4, 9, 16, 25}]
So it seems that we can't use a List as a Weight of a Vertex.
But the VertexWeight documentation says clearly
The weight can be any expression.
So I don't understant why gg
works well whereas g
doesn't work.
Best Regards
List
is treated as an exception for some reason.VertexWeight -> foo /@ {1,4,16,25,}
works as stated in the docs. As an aside, if you really have to useList
s as weights, you could useVertexWeight -> (Defer /@ {{1}, {4}, {9}, {16}, {25}})
. $\endgroup$