gives an undirected graph from the directed graph g.
UndirectedGraph[{vw,…}]
uses rules vw to specify the graph g.
UndirectedGraph
gives an undirected graph from the directed graph g.
UndirectedGraph[{vw,…}]
uses rules vw to specify the graph g.
Details and Options
- The undirected edge uv is an edge in the resulting undirected graph if either of the directed edges uv or vu is an edge of g.
- UndirectedGraph works with directed graphs, multigraphs, and mixed graphs.
Examples
open all close allBasic Examples (1)
Scope (7)
The input is unchanged for undirected graphs:
UndirectedGraph[[image]]UndirectedGraph works with directed graphs:
UndirectedGraph[[image]]UndirectedGraph[[image]]UndirectedGraph[[image]]Use rules to specify the graph:
UndirectedGraph[{1 -> 3, 2 -> 1, 3 -> 6, 4 -> 6, 1 -> 5, 5 -> 4, 6 -> 1}]Directed edges with different directions convert to one undirected edge:
UndirectedGraph[[image]]UndirectedGraph works with large graphs:
g = AdjacencyGraph[SparseArray[{{i_, i_} -> 1, {i_, j_} /; j == i + 1 -> 1}, {10 ^ 6, 10 ^ 6}]];Timing[h = UndirectedGraph[g];]UndirectedGraphQ /@ {g, h}EdgeCount /@ {g, h}Properties & Relations (4)
An undirected graph can be constructed by a list of UndirectedEdge objects:
Graph[{UndirectedEdge[1, 2], UndirectedEdge[2, 3], UndirectedEdge[3, 1]}]UndirectedGraphQ[%]A graph is either undirected or directed:
g1 = [image];g2 = [image];UndirectedGraphQ /@ {g1, g2}DirectedGraphQ /@ {g1, g2}A symmetric adjacency matrix is interpreted to be an undirected graph:
(m = {{0, 1, 1}, {1, 0, 1}, {1, 1, 0}})//MatrixFormSymmetricMatrixQ[m]UndirectedGraphQ[AdjacencyGraph[m]]Use DirectedEdges->True to interpret it as a directed graph:
UndirectedGraphQ[AdjacencyGraph[m, DirectedEdges -> True]]The incidence matrix of an undirected graph has no negative entries:
g = Graph[{12, 23, 31}]UndirectedGraphQ[g]IncidenceMatrix[g]//MatrixFormRelated Guides
Text
Wolfram Research (2010), UndirectedGraph, Wolfram Language function, https://reference.wolfram.com/language/ref/UndirectedGraph.html (updated 2015).
CMS
Wolfram Language. 2010. "UndirectedGraph." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/UndirectedGraph.html.
APA
Wolfram Language. (2010). UndirectedGraph. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/UndirectedGraph.html
BibTeX
@misc{reference.wolfram_2026_undirectedgraph, author="Wolfram Research", title="{UndirectedGraph}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/UndirectedGraph.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_undirectedgraph, organization={Wolfram Research}, title={UndirectedGraph}, year={2015}, url={https://reference.wolfram.com/language/ref/UndirectedGraph.html}, note=[Accessed: 13-June-2026]}