HasSelfLoop - Maple Help

Online Help

All Products    Maple    MapleSim


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

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

withGraphTheory:

GGraph1,2,2,3,3,3,3,4,4,1

GGraph 1: a directed unweighted graph with 4 vertices, 4 arc(s), and 1 self-loop(s)

(1)

HasSelfLoopG,2

false

(2)

HasSelfLoopG,3

true

(3)

NumberOfSelfLoopsG

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.

See Also

Graph

HighlightEdges