1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
def placeDansGraphe(directed_graph):
nbPred = 0
noeudSansPred = []
tabDePredessesseur = []
passe = []
for n in directed_graph.nodes():
for pred in directed_graph.predecessors(n):
directed_graph.nodes[n]['estampille']=10
if 'estampille' not in directed_graph.nodes[n]:
directed_graph.nodes[n]['estampille']=1
noeudSansPred.append(n)
for n in directed_graph.nodes():
est = 1
for suiv in directed_graph.nodes():
if suiv not in noeudSansPred:
est = est +1
passe.append(n)
directed_graph.nodes[suiv]['estampille']=est
edges_list=[('p_0_1', 'p_0_2'),('p_0_2', 'p_0_3'),('p_1_1','p_1_2'),('p_1_2','p_1_3'),('p_1_3','p_0_2'),('p_2_1','p_2_2'),('p_2_1','p_1_2'),('p_2_2','p_2_3')] |
Partager