Hi Henrik,
@@@
is equivalent to for Apply[f, expr, {1}]
. Apply
changes the Head
of an expression.
l = {1, 2}
FullForm@l
(* List[1,2] *)
Replace List
with Plus
, then Plus
is evaluated.
Apply[Plus, l]
(* 3 *)
What Hans showed is exactly what you want
would like to turn that into a graph like this {2 -> 6, 2 -> 4, 4 ->
5, 5 -> 6} so that I can use functions like TreePlot and GraphPlot3D
The example listOfListsOfPairs
does not represent a tree, so Graph
is a better function to use than TreePlot
.
Rule @@@ listOfListsOfPairs // Graph[#, VertexLabels -> Automatic] &
Rule @@@ listOfListsOfPairs // GraphPlot3D[#, VertexLabels -> Automatic] &
To use DirectedEdge
or UndirectedEdge
rather than Rule
DirectedEdge @@@ listOfListsOfPairs
UndirectedEdge @@@ listOfListsOfPairs