1 | initial version |
If I understand well your construction in terms of graphs, each time you have arcs (u, v)
, (v, w)
and (u, w)
, so a transitive tournament on 3 vertices, you remove arc (u, w)
. This can be done as follows:
def toto(M):
D = DiGraph(M - identity_matrix(M.ncols()))
A = []
for u, v in D.edges(labels=False):
for w in D.neighbor_out_iterator(u):
if D.has_edge(v, w):
A.append((u, w))
D.delete_edges(A)
return D