Function Repository Resource:

ReflexiveGraphQ

Source Notebook

Test whether a graph is reflexive

Contributed by: Wolfram Staff (original content by Sriram V. Pemmaraju and Steven S. Skiena)

ResourceFunction["ReflexiveGraphQ"][g]

yields True if the graph g is reflexive and False otherwise.

Details and Options

A graph is reflexive if each vertex in the graph has an associated self-loop.

Examples

Basic Examples (2) 

Tuples form a reflexive graph:

In[1]:=
Tuples[CharacterRange["a", "e"], 2]
Out[1]=
In[2]:=
g = Graph[UndirectedEdge @@@ %]
Out[2]=
In[3]:=
ResourceFunction["ReflexiveGraphQ"][%]
Out[3]=

After deleting one of its self-loops, the graph is no longer reflexive:

In[4]:=
EdgeDelete[g, UndirectedEdge["d", "d"]]
Out[4]=
In[5]:=
ResourceFunction["ReflexiveGraphQ"][%]
Out[5]=

The divisibility relation between integers is reflexive since each integer divides itself:

In[6]:=
g = RelationGraph[(Mod[#1, #2] == 0) &, Range[6], VertexLabels -> "Name"]
Out[6]=
In[7]:=
ResourceFunction["ReflexiveGraphQ"][%]
Out[7]=

Version History

  • 1.0.0 – 01 July 2020

Related Resources

License Information