GraphTheory
HasSelfLoop
test if graph has a self-loop
NumberOfSelfLoops
count number of self-loops in graph
SelfLoops
construct list of self-loops in graph
Calling Sequence
Parameters
Description
Examples
Compatibility
HasSelfLoop(G)
HasSelfLoop(G, v)
NumberOfSelfLoops(G)
SelfLoops(G)
G
-
graph
v
vertex of the graph
If v is a vertex of the graph, HasSelfLoop(G,v) returns true if the graph G has an edge or arc v to itself, and false otherwise.
The NumberOfSelfLoops(G) command returns the number of self-loops in G.
The SelfLoops(G) command returns a set of self-loops in G.
Because the data structure for a graph is an array of sets of neighbors, the test for self-loop existence checks each neighbor set and the cost is O(n) where n is the number of vertices.
with⁡GraphTheory:
G≔Graph⁡1,2,2,3,3,3,3,4,4,1
G≔Graph 1: a directed graph with 4 vertices, 4 arc(s), and 1 self-loop(s)
HasSelfLoop⁡G,2
false
HasSelfLoop⁡G,3
true
NumberOfSelfLoops⁡G
1
The GraphTheory[HasSelfLoop], GraphTheory[NumberOfSelfLoops] and GraphTheory[SelfLoops] commands were introduced in Maple 2020.
For more information on Maple 2020 changes, see Updates in Maple 2020.
See Also
Graph
HighlightEdges
Download Help Document