Skip to main content

Questions tagged [trees]

For questions about tree graphs, or about tree data structures.

Filter by
Sorted by
Tagged with
5 votes
1 answer
490 views

Why is a head called a head?

The head of an expression In the Wolfram language / Mathematica, "everything is an expression," to quote a tutorial. I think that every expression has a head. According to the tutorial: The ...
Andrew's user avatar
  • 10.5k
2 votes
3 answers
360 views

Draw a tree with custom graphics and coordinates

I am trying to make a Mathematica version of the following binary tree: I want the nodes and lines to be represented by Graphics[] objects (...
ap21's user avatar
  • 587
1 vote
2 answers
173 views

Draw a probability tree like this

I am trying to draw a probability tree like this I have never use tree in Mathematica, therefore, I don't know how to start. How can I draw the above tree? I Know that, using Mathematica calculus ...
minhthien_2016's user avatar
2 votes
0 answers
87 views

How to create a timeline branching graphics as shown in "Loki" one of the MCU TV programmes [closed]

How to create a timeline image as shared below
user444's user avatar
  • 2,720
1 vote
0 answers
41 views

Why does SetOptions[Tree,ImageSize->Tiny] fail for Tree[]

It works for Plot but not for Tree ...
Tapiocaweasel's user avatar
4 votes
1 answer
107 views

Tree edge label visibility and legibility

I am building some tools to help me visualize fitting of generic n-dimensional nonlinear model. I have the data and results stored in a nested association. I've written a few functions to generate a <...
Tapiocaweasel's user avatar
4 votes
1 answer
119 views

ExpressionTree issues

I can't see what I'm doing wrong in the following - I'd like to import some XML as a Tree (for structure visualisation) and convert it to an Association for ...
EstabanW's user avatar
  • 720
3 votes
1 answer
81 views

Percent symbol with FontFamily setting looks weird in Dendrogram

Bug introduced in 12.3.1 or earlier, persisting through 13.3.1. ...
Y. zeng's user avatar
  • 567
2 votes
2 answers
132 views

How can I make the output of Reduce more readable (with a tree)?

Oftentimes, the output of Reduce is quite difficult to read because it has too many && and ...
ions me's user avatar
  • 1,095
3 votes
3 answers
417 views

Better way to do such iteration

Consider such an iteration function ...
matrix42's user avatar
  • 7,210
2 votes
0 answers
94 views

Make Tree output wider?

I use Tree and what I have in the nodes is somewhat larger output (horizontally). That means the nodes are displayed with a lot of overlap. Is there a way to make the "outgoing" edges to the ...
Andreas Lauschke's user avatar
6 votes
1 answer
177 views

How can I make the vertices of a tree graph clickable?

Would it be possible to make the vertices of a tree graph clickable, executing a function when clicked? Specifically, I am using Mathematica / the Wolfram Language to prototype a modern, microtonal ...
Frank O'Neill's user avatar
2 votes
1 answer
90 views

Visualizing order of operations

TreeForm[HoldForm[ (9-2^2+10 8)/9]] produces this: Is there a way to use Divide instead of ...
Geremia's user avatar
  • 528
1 vote
2 answers
154 views

Display Binary Tree as Centred Array

I would like to display a binary tree using something analogous to TableForm. For example, a small such tree is given by this array (which except for the root still ...
pdini's user avatar
  • 485
3 votes
2 answers
299 views

How to display a tree with a root at the bottom but leaves in left-to-right order?

With the Tree function, I can draw arbitrary trees: Tree[f, {1, 2, 3}] However, real trees grow from the ground to the sky. ...
Najib Idrissi's user avatar
1 vote
0 answers
30 views

TreePosition with multiple (not just node data) conditions

Given a Tree object, TreePosition takes patterns only on the "data" of the node plus a level spec. ...
user5601's user avatar
  • 3,790
8 votes
4 answers
582 views

How to get all nodes in Tree?

What is the most efficient way to get the nodes of a Tree? ...
M.R.'s user avatar
  • 31.8k
5 votes
2 answers
404 views

Simple Decision Tree for Tuples

I would like to create a simple decision tree for a 3-course meal that looks something like the following: The tuples can be created using the code: ...
B flat's user avatar
  • 6,016
9 votes
1 answer
166 views

How to change TreeForm style?

I use t = ArrayReshape[Range@12, {2, 2, 3}]; t // TreeForm get "TreeForm" ,like this I want to make a change to the "TreeForm",like this: I ...
我心永恒's user avatar
  • 1,630
0 votes
1 answer
49 views

Why level 1,-1,2,3 in a data set containing 10 real numbers are the same? As shown in the following figure! [closed]

Why level 1,-1,2,3 in a data set containing 10 real numbers are the same? As shown in the following figure!
Lawrence's user avatar
0 votes
1 answer
69 views

How to find all functions that accept level specifications as an argument?

How can I find a list of every function that takes a level specification as an argument?
Peter Burbery's user avatar
1 vote
0 answers
75 views

How to find all the tree leaves of an expression?

I'd like to better understand what mathematica is doing during simplification, so I tried expression //TreeForm //TreeLeaves to see what it's picking up on. Except ...
ions me's user avatar
  • 1,095
0 votes
0 answers
42 views

FindSpanningTree not working properly on directed graph with negative weights

The code: ...
user3257842's user avatar
1 vote
2 answers
184 views

Is there a way to make FindSpanningTree return a directed graph?

I would like to use edge-direction to distinguish between parents and children in a given spanning tree. When choice of root-node is not unique FindSpanningTree ...
user3257842's user avatar
2 votes
2 answers
177 views

According to the path, how to draw such a binary tree?

As shown in the figure, the path can be generated by the following code ...
expression's user avatar
  • 5,692
4 votes
2 answers
139 views

Preventing truncation of trees

In regards to the new tree functionality in Mathematica 12.3, apparently the display is collapsed/summarized when an element has more than 10 sub-elements, so what I was expecting to be displayed as ...
Gustavo Delfino's user avatar
8 votes
0 answers
260 views

Improving label collisions for Tree/Graph?

Historically, MMA has never handled label collisions well, but recently they added some improvements here via things like Callout. I want to fix ImageSize but still ...
M.R.'s user avatar
  • 31.8k
10 votes
5 answers
748 views

How to construct a tree from a preorder traversal

The list t1 = {1, 2, 3, 3, 4, 4, 3, 3, 4, 3, 3, 2, 3, 4, 2, 3, 2}; might be derived from a pre-order traversal of ...
High Performance Mark's user avatar
0 votes
1 answer
154 views

Add list of vectors to list of vectors recursively

This question relates to Add a vector to a list of vectors whereas here I want to add list of vectors to list of vectors recursively. Given: ...
user57467's user avatar
  • 2,930
0 votes
1 answer
164 views

How to generate a graph and determine its maximum spanning tree in Wolfram Mathematica? [closed]

I have just started learning Mathematica. I am trying to generate the following edge labeled graph $G$, and its maximum spanning tree using Wolfram Mathematica. Note. A maximum spanning tree is a ...
gete's user avatar
  • 21
13 votes
1 answer
276 views

How to draw the tree in a "pitchfork" form?

How to set the options or other parameters in a TreePlot to draw the branching outside of the vertex? I.e. in a form similar to a dendrogram (but the dendrogram plot itself does not support the ...
Slepecky Mamut's user avatar
3 votes
3 answers
1k views

Find all spanning tree in a given graph

Is there a way I can generate all the spanning tree in the following graph: Also, is there a way to insert the adjacency matrix, then I get an output of all possible spanning trees? The adjacency ...
Mubarak Alsaeedi's user avatar
4 votes
1 answer
318 views

Find all non-isomorphic trees with $n$ nodes

I would like to compute all non-isomorphic trees with n nodes efficiently. I use the following approach: I create all possible trees ( Visualizing Cayley's Formula in Mathematica) and filter the ...
Kiril Danilchenko's user avatar
2 votes
1 answer
76 views

How do I reference a string as the root node of a graph?

I've produced the following tree plot: But I want the root to be $a$, which is a string. I looked at the documentation, it says: So it seems it's very easy, we just write something like: ...
Red Banana's user avatar
  • 5,573
3 votes
0 answers
146 views

How to "program in binary trees" with Mathematica?

I want to do the following: f[x_] := If[OddQ[x[[1]]], Nothing, x/2 // Simplify] A = Table[2 (n + k), {k, 0, 4}]/2 n = 2 n1; f /@ A n = 2 n1 + 1; f /@ A This ...
Red Banana's user avatar
  • 5,573
2 votes
1 answer
48 views

A simple way to create graphs of series and parallel networks?

I tried TreePlot[{{G -> M, "p1"}, {M -> D, "p2"}}, Left, VertexLabeling -> True] I was hoping the graph would look like a horizontal ...
florin's user avatar
  • 2,166
6 votes
5 answers
646 views

Construct a permutation tree plot

How to construct a tree like this? I was looking CompleteKaryTree initially, there are some similarities overall, but it's still different. ...
matrix42's user avatar
  • 7,210
5 votes
1 answer
173 views

Visualizing directories--a cleaner view of a helpful older post

I am looking to make graphics of a folder hierarchy, and this old post was very helpful. However, this method gives the whole file path for each node, which makes a complete mess in the directory I ...
KBL's user avatar
  • 653
1 vote
1 answer
40 views

InputField and TreeForm problem

I want to use the expression enter by the user and form the Tree, so I did TreeForm[test] as the picture show but it's not working. But if I do it manually, it works. Can anyone explain to me why ...
David's user avatar
  • 93
5 votes
1 answer
223 views

Compute all trees on a given label set

Given a set of labels {a_1,...,a_n} (with some labels possibly appearing multiple times) I would like to efficiently compute all trees with n leaves labelled {a_1,...,a_n} and 2n-2 nodes. This is ...
Madeline Brandt's user avatar
5 votes
2 answers
126 views

How to draw a tree in which each vertex contains some circles inside?

I would like to recreate the following picture in Mathematica. I know how to draw a tree with GraphLayout. But I don't know how to create the shape of nodes as below. A bit hints about where to start ...
LeafGlowPath's user avatar
  • 1,473
1 vote
1 answer
269 views

Construct a binary tree where nodes are labeled according to given rule

I want to plot a binary tree in Mathematica where the nodes are labeled according to a given rule. In fact, whether a node has a left child or a right child or both, will be determined by a rule. And ...
Mwen Rele's user avatar
0 votes
0 answers
178 views

Is a tree structure possible in Mathematica?

Let's say I have a vector, vector={1,2,3,4,5,6,7}; and I want to use its items as leaf nodes in a tree datasctructure, then work with them as such, adding new ...
Vojtevo's user avatar
  • 63
17 votes
2 answers
1k views

How to draw a "proper" tree diagram

...
CasperYC's user avatar
  • 1,652
4 votes
1 answer
78 views

How do I build a position index of a general held expression to arbitrary depth?

I have an expression which I would like to make a position index of, which for sake of argument will be this: expr = f[q + g[x, y, z]]; Since it's not a list, ...
Pillsy's user avatar
  • 18.6k
2 votes
1 answer
264 views

Visualize tree with many children per node

I have some data that I would like to visualize as a tree. It contains the parent node and its children. I already looked up TreeForm and TreeGraph but the problem is, that my parent node got about 80 ...
Arji's user avatar
  • 1,134
6 votes
1 answer
170 views

How can I make TreeForm think some elements are atomic?

I want to apply TreeForm to some expressions of the form m[m[m[y[1], y[1]], x[1]], z], but I want Mathematica to treat ...
Fernando Martin's user avatar
1 vote
1 answer
556 views

How to construct a specific binary tree from a particular set of information?

I run a algorithm to solve a problem that return a set of information relative to a binary tree associated with these problem. For illustrate the results obtained I try to plot the binary tree. I make ...
Student's user avatar
  • 111
5 votes
1 answer
219 views

Steiner Tree Approximation

I am wondering about the existence of Mathematica code to find (approximate) Steiner trees in graphs. I know there are a number of algorithms to do so --- just curious if anyone has implemented any ...
JHarris's user avatar
  • 51
4 votes
3 answers
173 views

Set the parent of each child while iterating over a List

I'm still new to this language and have tried a number of ways with no success. I have a list of keys with values. These values are used to identify the parent of the current item. The list is ...
Sam B's user avatar
  • 169