Function Repository Resource:

MergeTree

Source Notebook

Merge subtrees of a tree into a graph

Contributed by: Nikolay Murzin

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"].

Details and Options

ResourceFunction["MergeTree"] works on Tree objects.
ResourceFunction["MergeTree"] works on trees with Head Graph (i.e. objects for which TreeGraphQ is True) by using GraphTree to convert them to Tree objects.
The default merging function is Hash.
EdgeTags of a resulting graph contain original tree edge information as a tagged DirectedEdge object whose tag is the node's child index.
ResourceFunction["MergeTree"] accepts the same options as Graph.
ResourceFunction["MergeTree"] takes the following additional options:
"VertexLabelFunction"Automaticfunction applied to an association of tree positions and tree data values to label vertices, default is Row[Values[#],","]&

Examples

Basic Examples (2) 

Merge identical subtrees of a tree:

In[1]:=
ResourceFunction["MergeTree"][\!\(\*
GraphicsBox[
NamespaceBox["Trees",
DynamicModuleBox[{Typeset`tree = HoldComplete[
Tree[$CellContext`f, { Tree[$CellContext`g, {
Tree[$CellContext`a, None]}], 
Tree[$CellContext`g, {
Tree[$CellContext`a, None]}], 
Tree[$CellContext`g, {
Tree[$CellContext`b, None]}]}]]}, 
NamespaceBox[{
{RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765],
          AbsoluteThickness[1], Opacity[0.7], LineBox[{{0.8660254037844387, 1.7320508075688774`}, {0., 0.8660254037844387}}], LineBox[{{0.8660254037844387, 1.7320508075688774`}, {
          0.8660254037844387, 0.8660254037844387}}], LineBox[{{0.8660254037844387, 1.7320508075688774`}, {
          1.7320508075688774`, 0.8660254037844387}}], LineBox[{{0., 0.8660254037844387}, {0., 0.}}], LineBox[{{0.8660254037844387, 0.8660254037844387}, {
          0.8660254037844387, 0.}}], LineBox[{{1.7320508075688774`, 0.8660254037844387}, {
          1.7320508075688774`, 0.}}]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], 
TagBox[InsetBox[
FrameBox["f",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->4,
StripOnInput->False], {0.8660254037844387, 1.7320508075688774}],
"DynamicName",
BoxID -> "VertexID$1"], 
TagBox[InsetBox[
FrameBox["g",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->4,
StripOnInput->False], {0., 0.8660254037844387}],
"DynamicName",
BoxID -> "VertexID$2"], 
TagBox[InsetBox[
FrameBox["a",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->0,
StripOnInput->False], {0., 0.}],
"DynamicName",
BoxID -> "VertexID$3"], 
TagBox[InsetBox[
FrameBox["g",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->4,
StripOnInput->False], {0.8660254037844387, 0.8660254037844387}],
"DynamicName",
BoxID -> "VertexID$4"], 
TagBox[InsetBox[
FrameBox["a",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->0,
StripOnInput->False], {0.8660254037844387, 0.}],
"DynamicName",
BoxID -> "VertexID$5"], 
TagBox[InsetBox[
FrameBox["g",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->4,
StripOnInput->False], {1.7320508075688774, 0.8660254037844387}],
"DynamicName",
BoxID -> "VertexID$6"], 
TagBox[InsetBox[
FrameBox["b",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->0,
StripOnInput->False], {1.7320508075688774, 0.}],
"DynamicName",
BoxID -> "VertexID$7"]}}]]],
AlignmentPoint->Center,
Axes->False,
AxesLabel->None,
AxesOrigin->Automatic,
AxesStyle->{},
Background->None,
BaseStyle->Directive[
     FrontEnd`GraphicsHighlightColor -> RGBColor[
       0.403921568627451, 0.8705882352941177, 0.7176470588235294]],
BaselinePosition->Automatic,
ContentSelectable->Automatic,
Epilog->{},
FormatType->StandardForm,
Frame->False,
FrameLabel->FormBox["False", StandardForm],
FrameStyle->{},
FrameTicks->None,
FrameTicksStyle->{},
GridLines->None,
GridLinesStyle->{},
ImageMargins->0.,
ImagePadding->All,
ImageSize->Automatic,
LabelStyle->{},
PlotLabel->None,
PlotRange->All,
PlotRangeClipping->False,
PlotRangePadding->Automatic,
PlotRegion->Automatic,
Prolog->{},
RotateLabel->True,
Ticks->Automatic,
TicksStyle->{}]\)]
Out[1]=

Merge subtrees by a given function:

In[2]:=
ResourceFunction["MergeTree"][\!\(\*
GraphicsBox[
NamespaceBox["Trees",
DynamicModuleBox[{Typeset`tree = HoldComplete[
Tree[2, {
Tree[6, {
Tree[5, None], 
Tree[3, None], 
Tree[1, {
Tree[4, None]}]}]}]]}, 
NamespaceBox[{
{RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765],
          AbsoluteThickness[1], Opacity[0.7], LineBox[{{0.8451542547285166, 2.53546276418555}, {
          0.8451542547285166, 1.6903085094570334`}}], LineBox[{{0.8451542547285166, 1.6903085094570334`}, {0., 0.8451542547285167}}], LineBox[{{0.8451542547285166, 1.6903085094570334`}, {
          0.8451542547285166, 0.8451542547285167}}], LineBox[{{0.8451542547285166, 1.6903085094570334`}, {
          1.6903085094570331`, 0.8451542547285167}}], LineBox[{{1.6903085094570331`, 0.8451542547285167}, {
          1.6903085094570331`, 0.}}]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], 
TagBox[InsetBox[
FrameBox["2",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->4,
StripOnInput->False], {0.8451542547285166, 2.53546276418555}],
"DynamicName",
BoxID -> "VertexID$1"], 
TagBox[InsetBox[
FrameBox["6",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->4,
StripOnInput->False], {0.8451542547285166, 1.6903085094570334}],
"DynamicName",
BoxID -> "VertexID$2"], 
TagBox[InsetBox[
FrameBox["5",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->0,
StripOnInput->False], {0., 0.8451542547285167}],
"DynamicName",
BoxID -> "VertexID$3"], 
TagBox[InsetBox[
FrameBox["3",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->0,
StripOnInput->False], {0.8451542547285166, 0.8451542547285167}],
"DynamicName",
BoxID -> "VertexID$4"], 
TagBox[InsetBox[
FrameBox["1",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->4,
StripOnInput->False], {1.6903085094570331, 0.8451542547285167}],
"DynamicName",
BoxID -> "VertexID$5"], 
TagBox[InsetBox[
FrameBox["4",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->0,
StripOnInput->False], {1.6903085094570331, 0.}],
"DynamicName",
BoxID -> "VertexID$6"]}}]]],
AlignmentPoint->Center,
Axes->False,
AxesLabel->None,
AxesOrigin->Automatic,
AxesStyle->{},
Background->None,
BaseStyle->Directive[
     FrontEnd`GraphicsHighlightColor -> RGBColor[
       0.403921568627451, 0.8705882352941177, 0.7176470588235294]],
BaselinePosition->Automatic,
ContentSelectable->Automatic,
Epilog->{},
FormatType->StandardForm,
Frame->False,
FrameLabel->FormBox["False", StandardForm],
FrameStyle->{},
FrameTicks->None,
FrameTicksStyle->{},
GridLines->None,
GridLinesStyle->{},
ImageMargins->0.,
ImagePadding->All,
ImageSize->Automatic,
LabelStyle->{},
PlotLabel->None,
PlotRange->All,
PlotRangeClipping->False,
PlotRangePadding->Automatic,
PlotRegion->Automatic,
Prolog->{},
RotateLabel->True,
Ticks->Automatic,
TicksStyle->{}]\), OddQ@*TreeData]
Out[2]=

Scope (3) 

Use TreeFold to merge subtrees after folding them:

In[3]:=
ResourceFunction["MergeTree"][\!\(\*
GraphicsBox[
NamespaceBox["Trees",
DynamicModuleBox[{Typeset`tree = HoldComplete[
Tree[1, {
Tree[2, None], 
Tree[3, {
Tree[1, None], 
Tree[2, None]}], 
Tree[6, None]}]]}, 
NamespaceBox[{
{RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765],
          AbsoluteThickness[1], Opacity[0.7], LineBox[{{0.8164965809277261, 1.6329931618554523`}, {0., 0.8164965809277261}}], LineBox[{{0.8164965809277261, 1.6329931618554523`}, {
          0.8164965809277261, 0.8164965809277261}}], LineBox[{{0.8164965809277261, 1.6329931618554523`}, {
          1.6329931618554523`, 0.8164965809277261}}], LineBox[{{0.8164965809277261, 0.8164965809277261}, {
          0.4082482904638631, 0.}}], LineBox[{{0.8164965809277261, 0.8164965809277261}, {
          1.2247448713915892`, 0.}}]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], 
TagBox[InsetBox[
FrameBox["1",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->4,
StripOnInput->False], {0.8164965809277261, 1.6329931618554523}],
"DynamicName",
BoxID -> "VertexID$1"], 
TagBox[InsetBox[
FrameBox["2",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->0,
StripOnInput->False], {0., 0.8164965809277261}],
"DynamicName",
BoxID -> "VertexID$2"], 
TagBox[InsetBox[
FrameBox["3",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->4,
StripOnInput->False], {0.8164965809277261, 0.8164965809277261}],
"DynamicName",
BoxID -> "VertexID$3"], 
TagBox[InsetBox[
FrameBox["1",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->0,
StripOnInput->False], {0.4082482904638631, 0.}],
"DynamicName",
BoxID -> "VertexID$4"], 
TagBox[InsetBox[
FrameBox["2",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->0,
StripOnInput->False], {1.2247448713915892, 0.}],
"DynamicName",
BoxID -> "VertexID$5"], 
TagBox[InsetBox[
FrameBox["6",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->0,
StripOnInput->False], {1.6329931618554523, 0.8164965809277261}],
"DynamicName",
BoxID -> "VertexID$6"]}}]]],
AlignmentPoint->Center,
Axes->False,
AxesLabel->None,
AxesOrigin->Automatic,
AxesStyle->{},
Background->None,
BaseStyle->Directive[
     FrontEnd`GraphicsHighlightColor -> RGBColor[
       0.403921568627451, 0.8705882352941177, 0.7176470588235294]],
BaselinePosition->Automatic,
ContentSelectable->Automatic,
Epilog->{},
FormatType->StandardForm,
Frame->False,
FrameLabel->FormBox["False", StandardForm],
FrameStyle->{},
FrameTicks->None,
FrameTicksStyle->{},
GridLines->None,
GridLinesStyle->{},
ImageMargins->0.,
ImagePadding->All,
ImageSize->Automatic,
LabelStyle->{},
PlotLabel->None,
PlotRange->All,
PlotRangeClipping->False,
PlotRangePadding->Automatic,
PlotRegion->Automatic,
Prolog->{},
RotateLabel->True,
Ticks->Automatic,
TicksStyle->{}]\), TreeFold[#1 + Total[#2] &]]
Out[3]=

Annotate a graph with edge tags showing original tree hierarchy:

In[4]:=
ResourceFunction["MergeTree"][\!\(\*
GraphicsBox[
NamespaceBox["Trees",
DynamicModuleBox[{Typeset`tree = HoldComplete[
Tree[1, {
Tree[2, None], 
Tree[3, {
Tree[1, None], 
Tree[2, None]}], 
Tree[6, None]}]]}, 
NamespaceBox[{
{RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765],
          AbsoluteThickness[1], Opacity[0.7], LineBox[{{0.8164965809277261, 1.6329931618554523`}, {0., 0.8164965809277261}}], LineBox[{{0.8164965809277261, 1.6329931618554523`}, {
          0.8164965809277261, 0.8164965809277261}}], LineBox[{{0.8164965809277261, 1.6329931618554523`}, {
          1.6329931618554523`, 0.8164965809277261}}], LineBox[{{0.8164965809277261, 0.8164965809277261}, {
          0.4082482904638631, 0.}}], LineBox[{{0.8164965809277261, 0.8164965809277261}, {
          1.2247448713915892`, 0.}}]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], 
TagBox[InsetBox[
FrameBox["1",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->4,
StripOnInput->False], {0.8164965809277261, 1.6329931618554523}],
"DynamicName",
BoxID -> "VertexID$1"], 
TagBox[InsetBox[
FrameBox["2",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->0,
StripOnInput->False], {0., 0.8164965809277261}],
"DynamicName",
BoxID -> "VertexID$2"], 
TagBox[InsetBox[
FrameBox["3",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->4,
StripOnInput->False], {0.8164965809277261, 0.8164965809277261}],
"DynamicName",
BoxID -> "VertexID$3"], 
TagBox[InsetBox[
FrameBox["1",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->0,
StripOnInput->False], {0.4082482904638631, 0.}],
"DynamicName",
BoxID -> "VertexID$4"], 
TagBox[InsetBox[
FrameBox["2",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->0,
StripOnInput->False], {1.2247448713915892, 0.}],
"DynamicName",
BoxID -> "VertexID$5"], 
TagBox[InsetBox[
FrameBox["6",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->0,
StripOnInput->False], {1.6329931618554523, 0.8164965809277261}],
"DynamicName",
BoxID -> "VertexID$6"]}}]]],
AlignmentPoint->Center,
Axes->False,
AxesLabel->None,
AxesOrigin->Automatic,
AxesStyle->{},
Background->None,
BaseStyle->Directive[
     FrontEnd`GraphicsHighlightColor -> RGBColor[
       0.403921568627451, 0.8705882352941177, 0.7176470588235294]],
BaselinePosition->Automatic,
ContentSelectable->Automatic,
Epilog->{},
FormatType->StandardForm,
Frame->False,
FrameLabel->FormBox["False", StandardForm],
FrameStyle->{},
FrameTicks->None,
FrameTicksStyle->{},
GridLines->None,
GridLinesStyle->{},
ImageMargins->0.,
ImagePadding->All,
ImageSize->Automatic,
LabelStyle->{},
PlotLabel->None,
PlotRange->All,
PlotRangeClipping->False,
PlotRangePadding->Automatic,
PlotRegion->Automatic,
Prolog->{},
RotateLabel->True,
Ticks->Automatic,
TicksStyle->{}]\), TreeFold[#1 + Total[#2] &],
 EdgeLabels -> Placed["EdgeTag", {.5, {0, 1}}],
 VertexLabels -> Placed[Automatic, Center],
 VertexSize -> 0.1]
Out[4]=

Use the operator form of MergeTree:

In[5]:=
ResourceFunction["MergeTree"][Mod[TreeData[#], 5] &]@
 BlockRandom[RandomTree[10], RandomSeeding -> 10]
Out[5]=

Options (1) 

VertexLabelFunction (1) 

Use a custom function to label vertices:

In[6]:=
ResourceFunction["MergeTree"][\!\(\*
GraphicsBox[
NamespaceBox["Trees",
DynamicModuleBox[{Typeset`tree = HoldComplete[
Tree[1, {
Tree[2, None], 
Tree[3, {
Tree[1, None], 
Tree[2, None]}], 
Tree[6, None]}]]}, 
NamespaceBox[{
{RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765],
          AbsoluteThickness[1], Opacity[0.7], LineBox[{{0.8164965809277261, 1.6329931618554523`}, {0., 0.8164965809277261}}], LineBox[{{0.8164965809277261, 1.6329931618554523`}, {
          0.8164965809277261, 0.8164965809277261}}], LineBox[{{0.8164965809277261, 1.6329931618554523`}, {
          1.6329931618554523`, 0.8164965809277261}}], LineBox[{{0.8164965809277261, 0.8164965809277261}, {
          0.4082482904638631, 0.}}], LineBox[{{0.8164965809277261, 0.8164965809277261}, {
          1.2247448713915892`, 0.}}]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], 
TagBox[InsetBox[
FrameBox["1",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->4,
StripOnInput->False], {0.8164965809277261, 1.6329931618554523}],
"DynamicName",
BoxID -> "VertexID$1"], 
TagBox[InsetBox[
FrameBox["2",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->0,
StripOnInput->False], {0., 0.8164965809277261}],
"DynamicName",
BoxID -> "VertexID$2"], 
TagBox[InsetBox[
FrameBox["3",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->4,
StripOnInput->False], {0.8164965809277261, 0.8164965809277261}],
"DynamicName",
BoxID -> "VertexID$3"], 
TagBox[InsetBox[
FrameBox["1",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->0,
StripOnInput->False], {0.4082482904638631, 0.}],
"DynamicName",
BoxID -> "VertexID$4"], 
TagBox[InsetBox[
FrameBox["2",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->0,
StripOnInput->False], {1.2247448713915892, 0.}],
"DynamicName",
BoxID -> "VertexID$5"], 
TagBox[InsetBox[
FrameBox["6",
Background->Directive[
RGBColor[0.9607843137254902, 0.9882352941176471, 0.9764705882352941]],
            
BaseStyle->GrayLevel[0],
FrameStyle->Directive[
RGBColor[0.6588235294117647, 0.7294117647058823, 0.7058823529411765], AbsoluteThickness[1]],
ImageSize->Automatic,
RoundingRadius->0,
StripOnInput->False], {1.6329931618554523, 0.8164965809277261}],
"DynamicName",
BoxID -> "VertexID$6"]}}]]],
AlignmentPoint->Center,
Axes->False,
AxesLabel->None,
AxesOrigin->Automatic,
AxesStyle->{},
Background->None,
BaseStyle->Directive[
     FrontEnd`GraphicsHighlightColor -> RGBColor[
       0.403921568627451, 0.8705882352941177, 0.7176470588235294]],
BaselinePosition->Automatic,
ContentSelectable->Automatic,
Epilog->{},
FormatType->StandardForm,
Frame->False,
FrameLabel->FormBox["False", StandardForm],
FrameStyle->{},
FrameTicks->None,
FrameTicksStyle->{},
GridLines->None,
GridLinesStyle->{},
ImageMargins->0.,
ImagePadding->All,
ImageSize->Automatic,
LabelStyle->{},
PlotLabel->None,
PlotRange->All,
PlotRangeClipping->False,
PlotRangePadding->Automatic,
PlotRegion->Automatic,
Prolog->{},
RotateLabel->True,
Ticks->Automatic,
TicksStyle->{}]\), TreeFold[#1 + Total[#2] &], "VertexLabelFunction" -> f]
Out[6]=

Applications (1) 

Make a graph representation of AxiomaticTheory formulas:

In[7]:=
ResourceFunction["MergeTree"][
 ExpressionTree@AxiomaticTheory["BooleanAxioms"], "VertexLabelFunction" -> First]
Out[7]=

Version History

  • 1.0.0 – 24 January 2022

License Information