LoopFreeGraphQ
Examples
open all close allBasic Examples (2)
Test whether a graph has no self-loops:
GraphData["CubicalGraph"]LoopFreeGraphQ[%]LoopFreeGraphQ gives False for a graph with self-loops:
LoopFreeGraphQ[[image]]Scope (6)
LoopFreeGraphQ works with undirected graphs:
LoopFreeGraphQ[[image]]LoopFreeGraphQ[[image]]LoopFreeGraphQ[[image]]LoopFreeGraphQ[[image]]LoopFreeGraphQ gives False for anything that is not a graph without self-loops:
LoopFreeGraphQ[x]LoopFreeGraphQ[Graph[garbage]]LoopFreeGraphQ works with large graphs:
GridGraph[{10, 10, 10, 10}];LoopFreeGraphQ[%]//TimingProperties & Relations (5)
A bipartite graph has no self-loops:
Graph[{12, 11}]{BipartiteGraphQ[%], LoopFreeGraphQ[%]}A TreeGraph has no self-loops:
TreeGraph[{12, 13}]{TreeGraphQ[%], LoopFreeGraphQ[%]}A typical PathGraph has no self-loops:
PathGraph[{12, 23}]{PathGraphQ[%], LoopFreeGraphQ[%]}The adjacency matrix of a graph without self-loops has a zero diagonal:
g = PetersenGraph[5, 2]LoopFreeGraphQ[g]Diagonal[AdjacencyMatrix[g]]//NormalThe incidence matrix of a graph without self-loops has no entries greater than 1:
g = Graph[{12, 23, 31}]LoopFreeGraphQ[g]IncidenceMatrix[g]//MatrixFormPossible Issues (1)
LoopFreeGraphQ gives False for non-explicit graphs:
LoopFreeGraphQ[CompleteGraph[n]]See Also
Related Guides
History
Text
Wolfram Research (2010), LoopFreeGraphQ, Wolfram Language function, https://reference.wolfram.com/language/ref/LoopFreeGraphQ.html.
CMS
Wolfram Language. 2010. "LoopFreeGraphQ." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/LoopFreeGraphQ.html.
APA
Wolfram Language. (2010). LoopFreeGraphQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LoopFreeGraphQ.html
BibTeX
@misc{reference.wolfram_2026_loopfreegraphq, author="Wolfram Research", title="{LoopFreeGraphQ}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/LoopFreeGraphQ.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_loopfreegraphq, organization={Wolfram Research}, title={LoopFreeGraphQ}, year={2010}, url={https://reference.wolfram.com/language/ref/LoopFreeGraphQ.html}, note=[Accessed: 13-June-2026]}