Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

TensorNetworks

Guides

  • TensorNetworks

Tech Notes

  • Building Tensor Networks
  • Contraction Paths and Execution
  • Matrix Product States
  • A Working Tour of the Symmetry Functions
  • Tensor Networks Overview
  • Young Tableaux and Tensor Symmetries

Symbols

  • ActivateTensors
  • BinaryTensorNetwork
  • BinaryTensorNetworkQ
  • CanonicalPath
  • CanonicalPathQ
  • ContractIndices
  • ContractionTree
  • EinsteinSummation
  • GreedyContractionPath
  • HookFactor
  • HookLength
  • HookLengths
  • IndexedMultiply
  • InitializeTensorNetwork
  • MetricTensor
  • MetricTensorQ
  • MPSCanonicalForm
  • MPSCanonicalQ
  • MPSEntanglementEntropy
  • MPSNormalize
  • MPSNorm
  • MPSOverlap
  • MPSSchmidtValues
  • MPSTruncate
  • OptimalContractionPath
  • PartitionQ
  • PathIndexContractions
  • PathQ
  • PathToTreePath
  • RandomTensorNetwork
  • SchurDimension
  • SparseTensorNetwork
  • TableauColumns
  • TableauDimension
  • TableauRows
  • TableauShape
  • TableauSize
  • TableauWeylDimension
  • TensorNetworkAdd
  • TensorNetworkContraction
  • TensorNetworkContractions
  • TensorNetworkContract
  • TensorNetworkData
  • TensorNetworkDelete
  • TensorNetworkFreeIndices
  • TensorNetworkGraphData
  • TensorNetworkGraphQ
  • TensorNetworkIndexDimensions
  • TensorNetworkIndexGraph
  • TensorNetworkIndices
  • TensorNetwork
  • TensorNetworkQ
  • TensorNetworkRemoveCycles
  • TensorNetworkReplaceIndices
  • TensorNetworkSize
  • TensorNetworkTensors
  • TensorNetworkToNetGraph
  • ToTensorNetworkGraph
  • TransposePartition
  • TreePathQ
  • TreePathToPath
  • YoungProject
  • YoungSymmetrize
  • YoungTableau
  • YoungTableauQ
Wolfram`TensorNetworks`
PathToTreePath
​
PathToTreePath
[path]
converts a linear pairwise contraction
path
to a nested tree-form path with auto-derived integer leaves.
​
​
PathToTreePath
[path,indices]
uses the explicit list
indices
as the leaf labels.
​
Details and Options
▪
The tree form is a nested list whose leaves are singleton lists
{x}
and whose non-leaf nodes group two or more children. It is the same form recognised by
TreePathQ
and consumed by
TreePathToPath
.
▪
The required arity — the number of leaves of the resulting tree — is
Count
[path,{_,_}]
+ 1: one leaf for each binary contraction step in
path
, plus one for the initial tensor count.
▪
When
indices
is omitted it defaults to
Automatic
, and the leaves are taken from
Range
[required]
.
▪
If an explicit
indices
list is given whose length does not match the required arity,
PathToTreePath
issues
PathToTreePath::indlen
and returns
$Failed
.
▪
At each step the underlying fold deletes the contracted positions from the working list and appends either the chosen leaf (singleton step) or the pair of children (binary step) as a tree-level node, so the order in which leaves appear in the output is determined by the path.
​
Examples  
(10)
Basic Examples  
(4)
The simplest pairwise path produces a two-leaf tree:
In[1]:=
PathToTreePath
[{{1,2}}]
Out[1]=
{{1},{2}}
​
A two-step path builds a deeper tree; the last leaf appears at the top of the tree:
In[1]:=
PathToTreePath
[{{1,2},{1,2}}]
Out[1]=
{{3},{{1},{2}}}
​
Pass an explicit list of leaf labels:
In[1]:=
PathToTreePath
[{{1,2}},{x,y}]
Out[1]=
{{x},{y}}
​
Derive the leaf labels from a tensor network and pass them as the second argument; the result is the tree path induced by a
GreedyContractionPath
:
In[1]:=
tn=
RandomTensorNetwork
["MPS"[4,3,2]]
In[2]:=
path=
GreedyContractionPath
[tn]
Out[2]=
{{2,3},{1,3},{1,2}}
In[3]:=
PathToTreePath
[path,tn["Vertices"]]
Out[3]=
{{4},{{1},{{2},{3}}}}
Scope  
(4)

Applications  
(1)

Properties & Relations  
(1)

SeeAlso
TreePathToPath
 
▪
CanonicalPath
 
▪
PathQ
 
▪
CanonicalPathQ
 
▪
TreePathQ
 
▪
PathIndexContractions
TechNotes
▪
Contraction Paths and Execution
RelatedGuides
▪
TensorNetworks
""

© 2026 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com