UndirectedEdge[u,v] or uv
represents an undirected edge between u and v.
UndirectedEdge[u,v,t] or u
v
represents an undirected edge between u and v with tag t.
UndirectedEdge 
UndirectedEdge[u,v] or uv
represents an undirected edge between u and v.
UndirectedEdge[u,v,t] or u
v
represents an undirected edge between u and v with tag t.
Details
- UndirectedEdge is also known as link or connection.
- UndirectedEdge[u,v] can be input as uv. The character is entered as
ue
or \[UndirectedEdge]. - UndirectedEdge[u,v,t] can be input as u
v. An empty template
can entered as
tue
, and
moves the cursor to the overscript position.
Examples
open all close allBasic Examples (5)
Build a graph with undirected edges:
Graph[{UndirectedEdge[a, b], UndirectedEdge[b, c], UndirectedEdge[c, a]}]EdgeList[%]Graph[{ab, bc, ca}]EdgeList[%]Enter using a two-way rule <->:
Graph[{a <-> b, b <-> c, c <-> a}]The two-way rules are converted to undirected edges:
EdgeList[%]Style and label individual edges:
Graph[{Style[ab, Red], Style[bc, Dashed], Labeled[ca, "hello"]}]StandardForm formatting:
UndirectedEdge[a, b]UndirectedEdge[a, b, t]Scope (6)
Use wrappers to specify edge properties, including style:
Graph[{Style[12, Red], 23, 31}]Graph[{Labeled[12, "Hello"], 23, 31}]Graph[{Button[Style[12, Red], Speak["Hello"]], 23, 31}]Wrappers can be used to specify any supported edge annotation:
Graph[{Annotation[12, EdgeStyle -> Red], 23, 31}]Graph[{Annotation[12, "foo" -> 17], 23, 31}]AnnotationValue[{%, 12}, "foo"]Use UndirectedEdge to specify individual edges for options, including style:
CompleteGraph[3, EdgeStyle -> {12 -> Red}]CompleteGraph[3, EdgeLabels -> {12 -> "Hello"}]Use a list of edges to indicate which edges to highlight:
HighlightGraph[CompleteGraph[4], {12, 23}]Subgraph[CompleteGraph[4], {12, 23}]Use edge patterns to select and count edges:
g = Graph[{12, 23, 31, 34}]EdgeList[g, 2_]EdgeCount[g, 2_]Properties & Relations (3)
Use UndirectedEdge to construct undirected graphs:
Graph[{12, 23, 31}]TreeGraph[{12, 13, 14}]PathGraph[{12, 23, 34}]Inside graph constructors, TwoWayRule[a,b] is converted to UndirectedEdge[a,b]:
Graph[{a b, a c, a d}]EdgeList[%]The adjacency matrix of an undirected graph is symmetric:
Graph[{12, 23, 31}]AdjacencyMatrix[%]//MatrixFormSee Also
DirectedEdge Graph EdgeList EdgeCount TwoWayRule EdgeTaggedGraph IndexEdgeTaggedGraph EdgeTags
Characters: \[UndirectedEdge]
Related Guides
Text
Wolfram Research (2010), UndirectedEdge, Wolfram Language function, https://reference.wolfram.com/language/ref/UndirectedEdge.html (updated 2020).
CMS
Wolfram Language. 2010. "UndirectedEdge." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/UndirectedEdge.html.
APA
Wolfram Language. (2010). UndirectedEdge. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/UndirectedEdge.html
BibTeX
@misc{reference.wolfram_2026_undirectededge, author="Wolfram Research", title="{UndirectedEdge}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/UndirectedEdge.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_undirectededge, organization={Wolfram Research}, title={UndirectedEdge}, year={2020}, url={https://reference.wolfram.com/language/ref/UndirectedEdge.html}, note=[Accessed: 12-June-2026]}