Skip to main content

Questions tagged [trees]

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

Filter by
Sorted by
Tagged with
1 vote
0 answers
37 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
99 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
114 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
  • 710
3 votes
1 answer
76 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
122 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,001
3 votes
3 answers
415 views

Better way to do such iteration

Consider such an iteration function ...
matrix42's user avatar
  • 7,148
2 votes
0 answers
88 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
168 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
86 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
  • 478
1 vote
2 answers
136 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
290 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
29 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,695
8 votes
4 answers
570 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.6k
5 votes
2 answers
396 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
  • 5,595
8 votes
1 answer
154 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,572
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
67 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,001
0 votes
0 answers
41 views

FindSpanningTree not working properly on directed graph with negative weights

The code: ...
user3257842's user avatar
1 vote
2 answers
169 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
173 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,662
4 votes
2 answers
138 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
259 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.6k
10 votes
5 answers
687 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
147 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,788
0 votes
1 answer
146 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
271 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
299 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,411
3 votes
0 answers
143 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,411
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
  • 1,900
6 votes
5 answers
590 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,148
5 votes
1 answer
170 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
  • 643
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
206 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
117 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
247 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
172 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,642
4 votes
1 answer
76 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
243 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
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[1], y[1]], x[1]], z], but I want Mathematica to treat ...
Fernando Martin's user avatar
1 vote
1 answer
536 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
212 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
170 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
  • 159
4 votes
2 answers
97 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 ...
amator2357's user avatar
  • 1,394
4 votes
2 answers
103 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 ...
amator2357's user avatar
  • 1,394
7 votes
3 answers
460 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 ...
amator2357's user avatar
  • 1,394
10 votes
2 answers
304 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 ...
Ren Witcher's user avatar