Hot answers tagged

30 votes

Elegant implementation of factorial tree graph

Update 3: ExpressionGraph is now available in version 12.1. Update 2: a more streamlined version for 2D graphs: ...
kglr's user avatar
  • 392k
23 votes
Accepted

Cone Trees: map a graph onto geometric shape

To lay out a graph on a cone, you start by laying it out in a circular way. Then you add an appropriate "z coordinate" to each node position, proportionally to its distance form the centre. This is ...
Szabolcs's user avatar
  • 234k
23 votes

Elegant implementation of factorial tree graph

IGraph/M already has this built-in as IGSymmetricTree. You can specify the number of branches at each level. ...
Szabolcs's user avatar
  • 234k
23 votes
Accepted

Elegant implementation of factorial tree graph

here is my elegant implementation ...
ZaMoC's user avatar
  • 6,647
21 votes
Accepted

TreePlot does not give a "binary-looking" tree for a binary tree

The documentation says: TreePlot[g] attempts to choose the root so as to make trees have as few layers as possible. What it does not say is that edge directions are ignored when determining the ...
WReach's user avatar
  • 68.7k
21 votes
Accepted

How to work with phylogenetic trees?

Download the Phylogenetics` package here: Phylogenetics on GitHub (direct link to latest release: source zip), available on PackageData.net here. Documentation: notebook / pdf / dark themed pdf (for ...
István Zachar's user avatar
21 votes

How to draw a "proper" tree diagram

It's a fussy solution, but it works. ...
Szabolcs's user avatar
  • 234k
20 votes
Accepted

How to draw a "proper" tree diagram

We can use TreePlot (GraphComputation`TreePlotLegacy in versions 12.0+) with the hidden option ...
kglr's user avatar
  • 392k
15 votes
Accepted

TreeForm outputs different results for the same input, Why?

The difference between your two examples is that one uses packed arrays and the other doesn't. The lists generated by Range are, by default, packed. ...
Jason B.'s user avatar
  • 67.9k
15 votes
Accepted

Collapsible Tree

So I took a slightly different tack from lowriniak, making a tree object, rather than just using a tree hierarchy, but the result is much the same. What's worth noting, though, is that this gives you ...
b3m2a1's user avatar
  • 46.8k
15 votes

Elegant implementation of factorial tree graph

I don't know if you find this elegant. But I give it a try. ...
Henrik Schumacher's user avatar
13 votes
Accepted

How to construct a tree from a preorder traversal

Another way: ...
Michael E2's user avatar
  • 234k
12 votes

Combinatorica Functionality in Vers. 11.1.1

The problem is that you defined the Graph using M syntax and not Combinatorica syntax. For your example you should do: ...
Carl Woll's user avatar
  • 130k
11 votes
Accepted

Is there a way to draw a level tree?

GraphComputation`ExpressionGraph[expr /. List -> (List[List, ##] &)] ...
kglr's user avatar
  • 392k
11 votes
Accepted

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

...
kglr's user avatar
  • 392k
10 votes
Accepted

TreeGraph construction

Update 2: Relabeling vertices using VertexReplace: ...
kglr's user avatar
  • 392k
10 votes

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

Maybe something like this: ...
lericr's user avatar
  • 26.4k
9 votes
Accepted

How to really plot a binary tree?

One possibility is to somehow represent missing left and right nodes, but not to draw edges and vertices for those nodes. Something like this (not extensively tested): ...
Ivica M.'s user avatar
  • 206
9 votes
Accepted

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

It's explained on the doc page of GraphLayout. This documentation page is very long, and most of the information is under the Scope section, under specific layout ...
Szabolcs's user avatar
  • 234k
9 votes
Accepted

How to change TreeForm style?

What about using Tree with a TreeElementStyle option: ...
M.R.'s user avatar
  • 31.4k
8 votes
Accepted

Can trees be made into graphs?

You can use halirutan's makeTree function from this answer. Your purpose is slightly different than the purpose in that question, so the function can be simplified ...
C. E.'s user avatar
  • 70.4k
8 votes
Accepted

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

Clear[helper]; helper[tl_] := GroupBy[tl, First -> Rest, helper]; helper[{{n_}}] := n; helper@Transpose@Append[Flatten@vals]@Transpose@Tuples[dims] The idea is ...
vapor's user avatar
  • 7,881
8 votes
Accepted

How can I make TreeForm think some elements are atomic?

Since strings are atomic and are displayed as themselves in a tree, we can just replace the terms with their string counterparts. ...
NonDairyNeutrino's user avatar
8 votes
Accepted

Find all spanning tree in a given graph

...
kglr's user avatar
  • 392k
8 votes
Accepted

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

There are plenty of new functionalities for manipulating and styling trees in v13 (some of them present already in v12.3). For example: ...
Domen's user avatar
  • 21.9k
7 votes

How to generate a random tree?

In 12.3, RandomTree can be used to generate random labeled trees of a given size: Currently, this does not sample uniformly, but this will be fixed in a future version.
Ian Ford's user avatar
  • 521
7 votes

How to generate a random tree?

Most of the existing answers do not sample uniformly from the set of labelled trees. IGraph/M now has a function which guarantees uniform sampling, IGTreeGame. It ...
Szabolcs's user avatar
  • 234k
7 votes

VertexDelete Problem

No, this is not a bug in VertexDelete. Some background first: TreePlot, along with ...
Szabolcs's user avatar
  • 234k
7 votes

Cone Trees: map a graph onto geometric shape

You can construct graphs using Graph3D with proper layouts: ...
halmir's user avatar
  • 15k
7 votes

Collapsible Tree

I've made a start, but getting the vertices to stay static relative to each other is a challenge... Set up the values: ...
lowriniak's user avatar
  • 2,412

Only top scored, non community-wiki answers of a minimum length are eligible