 HasSelfLoop - Maple Help

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 HasSelfLoop(G) HasSelfLoop(G, v) NumberOfSelfLoops(G) SelfLoops(G) Parameters

 G - graph v - vertex of the graph Description

 • 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. Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $G≔\mathrm{Graph}\left(\left\{\left[1,2\right],\left[2,3\right],\left[3,3\right],\left[3,4\right],\left[4,1\right]\right\}\right)$
 ${G}{≔}{\mathrm{Graph 1: a directed unweighted graph with 4 vertices, 4 arc\left(s\right), and 1 self-loop\left(s\right)}}$ (1)
 > $\mathrm{HasSelfLoop}\left(G,2\right)$
 ${\mathrm{false}}$ (2)
 > $\mathrm{HasSelfLoop}\left(G,3\right)$
 ${\mathrm{true}}$ (3)
 > $\mathrm{NumberOfSelfLoops}\left(G\right)$
 ${1}$ (4) Compatibility

 • 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.