3
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – user9660
    Nov 16, 2014 at 14:20
  • 2
    $\begingroup$ Looks like 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 use Lists as weights, you could use VertexWeight -> (Defer /@ {{1}, {4}, {9}, {16}, {25}}) . $\endgroup$
    – kglr
    Nov 16, 2014 at 15:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.