I'm working with randomly generated digraphs. I need to verify that the graphs I have have a girth of at least, say 3.
The solution I used is the following:
- I generate a random adjacency matrix
- I create an igraph.Graph instance from the matrix
- I call .girth() method to check the girth is correct.
- If correct, I keep my process; otherwise I return to step 1.
However; sometimes I have graphs that definitly should not pass the girth check but they do. For instance: Graph with girth 2. have an girth 2: there are two pairs of vertices (a,b) with a,b, and b,a in the arcs.
My theory is that igraph do not understand these pair of vertices as a proper cycle; if that is the case how do I fix this?
For the record: here how goes my random generation:
M = np.zeros((n,n))
for i in range(n):
pick_list = [j for j in range(n) if j!=i]
x = random.sample(pick_list, outdegree)
for j in x:
M[i][j] = 1