# Questions tagged [trees]

139 questions
Filter by
Sorted by
Tagged with
58 views

### Percent symbol with FontFamily setting looks weird in Dendrogram

Bug introduced in 12.3.1 or earlier, persisting through 13.3.1. ...
107 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 ...
400 views

### Better way to do such iteration

Consider such an iteration function ...
74 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 ...
153 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 ...
78 views

### Visualizing order of operations

TreeForm[HoldForm[ (9-2^2+10 8)/9]] produces this: Is there a way to use Divide instead of ...
1 vote
118 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 ...
276 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. ...
1 vote
27 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. ...
496 views

### How to get all nodes in Tree?

What is the most efficient way to get the nodes of a Tree? ...
351 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: ...
129 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 ...
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!
62 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?
66 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 ...
36 views

The code: ...
1 vote
117 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 ...
150 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 ...
134 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 ...
249 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 ...
620 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 ...
131 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: ...
100 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 ...
263 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 ...
939 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 ...
246 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 ...
71 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: ...
118 views

### How to "program in binary trees" with Mathematica?

I want to do the following: f[x_] := If[OddQ[x[]], 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 ...
47 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 ...
498 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. ...
162 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 ...
1 vote
35 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 ...
150 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 ...
100 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 ...
1 vote
170 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 ...
147 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 ...
1k views

...
75 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, ...
162 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 ...
168 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, y], x], z], but I want Mathematica to treat ...
1 vote
428 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 ...
182 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 ...
151 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 ...
94 views

### Issue with displaying a tree graph after deleting a vertex

Say, I have an expression tree: g = IGExpressionTree[ {{{1,2},{{3,4},{5,6}}},7}, VertexLabels -> "Name"] From that tree I want to delete all the vertices ...
96 views

### Adding edges to a TreeForm of an expression

Say I have an expression {1,{{2,3},4}}. It's TreeForm looks as follows: {1,{{2,3},4}} //TreeForm Now, on each level of that ...
446 views

### TreeGraph construction

I have a list l={{1,1},{2,3},{2,3,2,3,4}}. Based on that list, I want to draw a tree. Starting from a single point at the top of a tree, I proceed as follows, using ...
284 views

### How to explain the behaviour of TreeForm? [duplicate]

Just try this: g=1;a=1;TreeForm[Hold[g[a]]] The weird thing in the outcome is that the node of g displays 1 ,and a is still a. I do not know how to explain ...
276 views

### How to invert MapIndexed on a ragged structure? How to construct a tree from rules?

I have an arbitrary ragged nested list-of-lists (a tree) like A = {{a, b}, {c, d}, {{{e, f, g, h, i}, {j, k, l}}, m}, n}; Its structure is given by the rules <...