UndirectedGraphQ
Examples
open all close allBasic Examples (2)
Test whether a graph is undirected:
Graph[{12, 23, 31}]UndirectedGraphQ[%]UndirectedGraphQ gives False for inputs that are not undirected graphs:
Graph[{12, 23, 31, 34}]UndirectedGraphQ[%]Scope (6)
UndirectedGraphQ works with undirected graphs:
UndirectedGraphQ[[image]]UndirectedGraphQ[[image]]UndirectedGraphQ[[image]]UndirectedGraphQ[[image]]UndirectedGraphQ gives False for anything that is not an undirected graph:
UndirectedGraphQ[x]UndirectedGraphQ[Graph[garbage]]UndirectedGraphQ works with large graphs:
GridGraph[{10, 10, 10, 10}];UndirectedGraphQ[%] // TimingProperties & Relations (5)
The empty graphs are undirected graphs:
{EmptyGraphQ[[image]], UndirectedGraphQ[[image]]}An undirected graph can have self-loops:
Graph[{12, 22}]{UndirectedGraphQ[%], LoopFreeGraphQ[%]}A graph is either undirected or directed:
{g1, g2} = {Graph[{12, 13}], Graph[{12, 21}]}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 |);SymmetricMatrixQ[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]//MatrixFormPossible Issues (1)
UndirectedGraphQ gives False for non-explicit graphs:
UndirectedGraphQ[CompleteGraph[n]]See Also
Related Guides
History
Text
Wolfram Research (2010), UndirectedGraphQ, Wolfram Language function, https://reference.wolfram.com/language/ref/UndirectedGraphQ.html.
CMS
Wolfram Language. 2010. "UndirectedGraphQ." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/UndirectedGraphQ.html.
APA
Wolfram Language. (2010). UndirectedGraphQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/UndirectedGraphQ.html
BibTeX
@misc{reference.wolfram_2026_undirectedgraphq, author="Wolfram Research", title="{UndirectedGraphQ}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/UndirectedGraphQ.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_undirectedgraphq, organization={Wolfram Research}, title={UndirectedGraphQ}, year={2010}, url={https://reference.wolfram.com/language/ref/UndirectedGraphQ.html}, note=[Accessed: 13-June-2026]}