WLJS LogoWLJS Notebook

LoopFreeGraphQ

LoopFreeGraphQ[g] yields True if the graph g has no self-loops, and False otherwise.

Examples

Check if a graph has no self-loops:

LoopFreeGraphQ[Graph[{1 -> 2, 2 -> 3}]]

A graph with a self-loop:

LoopFreeGraphQ[Graph[{1 -> 1, 1 -> 2}]]

Please visit the official Wolfram Language Reference for more details.

On this page