# Questions tagged [trees]

For questions about the data structures known as trees.

105 questions
Filter by
Sorted by
Tagged with
54 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, ...
25 views

### Exhaustive search by using a tree without specifying all the nodes

I'm trying to draw a tree to visualize an exhaustive search without specifying all the nodes' positions in the graph. For example, I'd like to build a tree so that, given n=4 objects, the nodes with ...
60 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 ...
157 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 ...
121 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 ...
67 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 ...
118 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 ...
60 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 ...
75 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 ...
312 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 ...
57 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 ...
216 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 ...
33 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 <...
343 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: ...
35 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 ...
393 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 ...
144 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 ...
144 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:- ...
147 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 <...
79 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 ...
249 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 ...
457 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. ...
81 views

795 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 ...
778 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. ...
585 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 ...
1k 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 ...
202 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: ...