# Questions tagged [trees]

For questions about the data structures known as trees.

103 questions
Filter by
Sorted by
Tagged with
55 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 ...
156 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 ...
100 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 ...
63 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 ...
113 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 ...
58 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 ...
71 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 ...
303 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 ...
33 views

### Segment tree implementation

I want to implement a segment tree visualization. I was looked for implementation in WL but didn't find. Before I'm implementing it by myself, maybe anyone knows about some implementation that will be ...
212 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 ...
32 views

### How to represent nodes in a probability tree

I was trying to investigate the following problem I made up: A bag contains n distinctly coloured marbles. A marble is drawn at random. It is replaced and a second identical marble of the same colour ...
248 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 <...
334 views

### Is there a way to draw a level tree?

Consider the following expression. expr = {a, {b1, b2}, {c, {d1, d2}}}; One can get the levels in an expression as follows: ...
33 views

I am not sure to really understand how the function Apply works at level 2 for example. I have read this question and few others and it doesn't help me :Levels: how do they work? Take the following ...
301 views

### Semantic tableaux generator

I would like to use Mathematica to automatically generate a semantic tableaux (truth tree) from a formula in propositional logic). Here is an example formula: $$(a \lor\lnot b )\land b$$ Here is ...
125 views

### How to randomly generate Tree or Nested List of Function in Mathematica?

In detail, I want to generate randomly something like Divide[Add[X,Times[X,Y]],Times[X,3]] or {Divide,{Add,X,{Times{X,Y}}},{Times,X,3}} (Specified Function(# of argument is from 2 to 5)) + ...
1k views

### Elegant implementation of factorial tree graph

Consider the tree graph used in part of my solution to this question: Each level $i$ has $i!$ nodes, and the branching ratio is $i+1$: I kludged together code to generate this graph (with code ...
134 views

### How to connect all points in a graph generated by a set of given vertexes?

I am trying to construct a tree by looking at the nearest neighbors (or just approximately nearest for higher efficient) of a set of given vertexes. I first try this:- ...
132 views

### How can I extract weights labelling edges starting from a fixed set of vertices

Let g be a directed weighted graph (in particular is tree). Given a set of vertices A, how can I extract the weights in a set <...
78 views

### paths in a weighted directed trees

Given an weighted directed tree, I have to write this: Given a vertex v, I should list all the vertex c such that there exist ...
236 views

### How can I create an Association from a multidimensional list of values and a list of keys?

Given a list of values such as vals = {{{{0., 633.25}, {642.96, 677.34}}, {{591.56, 632.45}, {634.9, 715.6}}}} and a list of "Dimensions" such as ...
449 views

### How to make a Tree diagram using images as vertices, that goes left to right

In Graph or TreeGraph, I can make the vertices images, but the tree always starts at the top. ...
79 views

757 views

### How to really plot a binary tree?

A binary tree is one that distinguishes left child from right child. However, in TreePlot you cannot specify which child is left, which is right, so the output is not a binary-looking tree. For ...
775 views

### TreePlot does not give a “binary-looking” tree for a binary tree

I use the following code to generate a binary tree with root 1. ...
575 views

### Cone Trees: map a graph onto geometric shape

Question Is it possible to map a Graph onto a geometric object such as a Cone? Motivation Visualizing large trees can be ...
959 views

### How to work with phylogenetic trees?

A phylogenetic tree can be represented as a comma-bracket string by the Newick format (see the Newick Standard, or this site for syntax details; here is an online tree visualizer). A simple Newick ...
200 views

### TreeForm outputs different results for the same input, Why?

Bug introduced in 8.0.4 or earlier and persisting through 11.0.1 First of all, please look at the below inputs and outputs: ...
1k views

### How do I create a recursive tree plot for the Fibonacci sequence?

I would like to create a plot that shows the recursive tree for the nth number of the fibonacci sequence, as the one below. http://faculty.ycp.edu/~dhovemey/fall2005/cs102/lecture/fib5.png Ideally, ...
166 views

### Minimal Spanning Tree with EdgeWeights

Given a graph with EdgeWeights, I'm finding the minimal spanning tree: ...