Function Repository Resource:

TransitiveGraphQ

Source Notebook

Test whether the binary relation defined by edges of a graph is transitive

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

ResourceFunction["TransitiveGraphQ"][g]

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

Details and Options

ResourceFunction["TransitiveGraphQ"][g] returns True if the binary relation defined by edges of the graph g is transitive.

Examples

Basic Examples (2) 

A directed graph formed by tuples is transitive:

In[1]:=
tuples = Tuples[CharacterRange["a", "e"], 2]
Out[1]=
In[2]:=
Graph[DirectedEdge @@@ tuples]
Out[2]=
In[3]:=
ResourceFunction["TransitiveGraphQ"][%]
Out[3]=

But the undirected graph formed by the same tuples is not:

In[4]:=
Graph[UndirectedEdge @@@ tuples]
Out[4]=
In[5]:=
ResourceFunction["TransitiveGraphQ"][%]
Out[5]=

The divisibility relation between integers is transitive since n|m implies m=kn for some integer k, so m|l implies n|l:

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

Version History

  • 1.0.0 – 01 July 2020

Related Resources

License Information