Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Merge subtrees of a tree into a graph
ResourceFunction["MergeTree"][tree] returns a directed acyclic graph (DAG) representation of tree with identical subtrees merged together. | |
ResourceFunction["MergeTree"][tree, f] merges tree based on applying the function f to each of its subtrees. | |
ResourceFunction["MergeTree"][f] represents an operator form of ResourceFunction["MergeTree"]. |
Merge identical subtrees of a tree:
In[1]:= |
Out[1]= |
Merge subtrees by a given function:
In[2]:= |
Out[2]= |
Use TreeFold to merge subtrees after folding them:
In[3]:= |
Out[3]= |
Annotate a graph with edge tags showing original tree hierarchy:
In[4]:= |
Out[4]= |
Use the operator form of MergeTree:
In[5]:= |
Out[5]= |
Use a custom function to label vertices:
In[6]:= |
Out[6]= |
This work is licensed under a Creative Commons Attribution 4.0 International License