1. But : Déterminisme de Temps d’exécution d’un algorithme heuristique (DFS)
Nomet prénom Wael Toumi
Spécialité Big Data & Analyse desdonnées
Le nœud de départ est « A »
Pseudo code DFS avec python :
fromtime importtime
graph = { 'a': {'d', 'h','g','b','c'},
'c': {'h', 'd'},
'd': {'e', 'b'},
'h': {'g'},
'g': {'b','f'},
'b':{'e','f'},
'f': {'e'},
'e':{}
}
t0=time();
def dfs(graph,depart):
pile=[]
nv=[]
pile.append(depart)
while pile:
2. But : Déterminisme de Temps d’exécution d’un algorithme heuristique (DFS)
noeud=pile[-1]
pile.pop()
if noeudnotinnv:
nv.append(noeud)
fori in graph[noeud]:
if i not innv:
pile.append(i)
print(nv)
dfs(graph,'a')
t1=time();
print("le tempsd'exécutionde DFSprend",round((t1-t0)*1000,0), 'ms')