3

I am a bit confused on how to distinguish a directed graph to be aperiodic or periodic. Wikipedia says this about aperiodic graphs:

'In the mathematical area of graph theory, a directed graph is said to be aperiodic if there is no integer k > 1 that divides the length of every cycle of the graph.'

For example is the graph below aperiodic or periodic. I believe the graph is not periodic but by wikipedia's definition it is periodic since integer k = 2 divides all cycles in the graph (AC and ACDB)

enter image description here

It would be great if someone could provide a method to distinguish if a graph is aperiodic or periodic. Maybe provide some examples of periodic and aperiodic graphs to help explain.

Thank you.

Jaman
  • 125
  • 1
  • 11

1 Answers1

2

Here's a short python implementation based on Networkx, for finding wether a graph is periodic:

import networkx as nx
from math import gcd
from functools import reduce

G = nx.DiGraph()
G.add_edges_from([('A', 'C'), ('C', 'D'), ('D', 'B'), ('B', 'A'), ('C', 'A')])
cycles = list(nx.algorithms.cycles.simple_cycles(G))
cycles_sizes = [len(c) for c in cycles]
cycles_gcd = reduce(gcd, cycles_sizes)
is_periodic = cycles_gcd > 1
print("is_periodic: {}".format(is_periodic))

The code does the following:

  • Build the graph from your example (by specifying the edges).
  • List all cycles (AC and ACDB).
  • List all cycles sizes [2, 4].
  • Find greatest common denominator (GCD).
  • If GCD is 1 it means the graph is aperiodic, otherwise it's periodic by definition.

The graph you have given above in not aperiodic as it has the period of 2. (i.e. every node can return to itself in multiples of 2 steps)

You can play with different examples to get better intuition, and also visualize your graph by adding:

import matplotlib.pyplot as plt
nx.draw_networkx(G, with_labels=True)
plt.show()
zohar.kom
  • 1,765
  • 3
  • 12
  • 28