({{, (RefLink[LoopFreeGraphQ, paclet:ref/LoopFreeGraphQ])[g] 
yields (RefLink[True, paclet:ref/True]) if the graph g has no self-loops, and (RefLink[False, paclet:ref/False]) otherwise.}})

OpenersNotesSection(Spacer1)Details

A self-loop in a graph is an edge that connects a vertex to itself.

OpenersPrimaryExamplesSection(Spacer1)Examples  (14)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Test whether a graph has no self-loops:

GraphData["CubicalGraph"]

LoopFreeGraphQ[%]

(RefLink[LoopFreeGraphQ, paclet:ref/LoopFreeGraphQ]) gives (RefLink[False, paclet:ref/False]) for a graph with self-loops:

LoopFreeGraphQ[]

OpenersExampleSection1(Spacer1)Scope  (6)

(RefLink[LoopFreeGraphQ, paclet:ref/LoopFreeGraphQ]) works with undirected graphs:

LoopFreeGraphQ[]

Directed graphs:

LoopFreeGraphQ[]

Multigraphs:

LoopFreeGraphQ[]

Mixed graphs:

LoopFreeGraphQ[]

(RefLink[LoopFreeGraphQ, paclet:ref/LoopFreeGraphQ]) gives (RefLink[False, paclet:ref/False]) for anything that is not a graph without self-loops:

LoopFreeGraphQ[x]

LoopFreeGraphQ[Graph[garbage]]

(RefLink[LoopFreeGraphQ, paclet:ref/LoopFreeGraphQ]) works with large graphs:

GridGraph[{10,10,10,10}];

LoopFreeGraphQ[%]//Timing

OpenersExampleSection4(Spacer1)Properties & Relations  (5)

A bipartite graph has no self-loops:

Graph[{1\[UndirectedEdge]2,1\[UndirectedEdge]1}]

{BipartiteGraphQ[%],LoopFreeGraphQ[%]}

A (RefLink[TreeGraph, paclet:ref/TreeGraph]) has no self-loops:

TreeGraph[{1\[UndirectedEdge]2,1\[UndirectedEdge]3}]

{TreeGraphQ[%],LoopFreeGraphQ[%]}

A typical (RefLink[PathGraph, paclet:ref/PathGraph]) has no self-loops:

PathGraph[{1\[UndirectedEdge]2,2\[UndirectedEdge]3}]

{PathGraphQ[%],LoopFreeGraphQ[%]}

The adjacency matrix of a graph without self-loops has a zero diagonal:

g = PetersenGraph[5,2]

LoopFreeGraphQ[g]

Diagonal[AdjacencyMatrix[g]]//Normal

The incidence matrix of a graph without self-loops has no entries greater than 1:

g=Graph[{1\[UndirectedEdge]2,2\[UndirectedEdge]3,3\[UndirectedEdge]1}]

LoopFreeGraphQ[g]

IncidenceMatrix[g]//MatrixForm

OpenersExampleSection5(Spacer1)Possible Issues  (1)

(RefLink[LoopFreeGraphQ, paclet:ref/LoopFreeGraphQ]) gives (RefLink[False, paclet:ref/False]) for non-explicit graphs:

LoopFreeGraphQ[CompleteGraph[n]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Graph, paclet:ref/Graph])  ▪  (RefLink[DirectedEdges, paclet:ref/DirectedEdges])  ▪  (RefLink[AcyclicGraphQ, paclet:ref/AcyclicGraphQ])  ▪  (RefLink[SimpleGraphQ, paclet:ref/SimpleGraphQ])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Graph Predicates and Properties, paclet:guide/GraphPredicates])}, {▪(RefLinkPlain[Graph Properties & Measurements, paclet:guide/GraphPropertiesAndMeasurements])}})}})