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`
TensorNetworkGraphQ
​
TensorNetworkGraphQ
[graph]
yields
True
if
graph
is a valid annotated tensor-network graph, and
False
otherwise.
​
​
TensorNetworkGraphQ
[graph,
True
]
prints diagnostic messages when
graph
fails validation.
​
​
TensorNetworkGraphQ
[
True
]
is the curried form: it returns a predicate that, applied to a graph, runs the verbose check.
​
Details and Options
▪
A valid tensor-network graph is a
Graph
in which every vertex carries two annotations: a
"Tensor"
(the underlying array) and an
"Index"
(a duplicate-free list of
Superscript
or
Subscript
labels).
▪
Two consistency rules must hold across the vertex annotations: each tensor's rank equals the length of its
"Index"
list, and the sum of all tensor ranks equals the count of distinct indices across all vertices.
▪
Edges in the graph may carry
{
src
i
,
tgt
j
}
tags identifying which output and input slots are contracted along that edge;
TensorNetworkGraphQ
focuses on the vertex annotations and does not separately validate edge tags.
▪
When the second argument is
True
, a failing check prints one of four diagnostic message tags:
msg1
(vertices not annotated with tensors),
msg2
(indices not a duplicate-free list of
Subscript
/
Superscript
heads),
msg3
(tensor ranks and indices incompatible), and
msg4
(edges not tagged with indices). Both vertex-annotation checks are exercised in current builds;
msg1
and
msg4
are reserved for stricter checks added in future revisions.
▪
TensorNetworkGraphQ
is the graph-form sibling of
TensorNetworkQ
: the latter tests
TensorNetwork
[…] expressions, while
TensorNetworkGraphQ
tests the annotated
Graph
produced by
ToTensorNetworkGraph
.
▪
Downstream functions including
TensorNetworkGraphData
,
TensorNetworkIndices
,
TensorNetworkTensors
, and
TensorNetworkIndexGraph
are guarded by
TensorNetworkGraphQ
, so they remain unevaluated on an invalid graph rather than producing a wrong answer.
​
Examples  
(7)
Basic Examples  
(1)
Build a valid annotated tensor-network graph and test it:
In[1]:=
SeedRandom[42];g=
ToTensorNetworkGraph

RandomTensorNetwork
["MPS"[4,2,2]];
In[2]:=
TensorNetworkGraphQ
[g]
Out[2]=
True
A plain Graph carries no "Tensor" or "Index" annotations, so the predicate returns False:
In[3]:=
TensorNetworkGraphQ
[Graph[{12,23}]]
Out[3]=
False
Pass True as a second argument to print the first failing check on a malformed graph:
In[4]:=
TensorNetworkGraphQ
[Graph[{12}],True]
Out[4]=
False
Scope  
(4)

Applications  
(1)

Properties & Relations  
(1)

SeeAlso
ToTensorNetworkGraph
 
▪
TensorNetworkGraphData
 
▪
TensorNetworkQ
 
▪
TensorNetwork
 
▪
TensorNetworkRemoveCycles
 
▪
TensorNetworkIndexGraph
 
▪
Graph
 
▪
AnnotationValue
 
▪
GraphQ
TechNotes
▪
Building Tensor Networks
RelatedGuides
▪
TensorNetworks
""

© 2026 Wolfram. All rights reserved.

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