Exemple #1
0
#Solution node can be found at depth 7
G2 = nx.DiGraph()  #Make graph
startNode = 'ABab|'
key = 0
G2 = makeNode_gotoCC(G2, startNode, key,
                     2)  #Create tree of depth one from root
depth2 = 6  #Depth of graph
G2 = makeGraph(G2, key, depth2, 2)  #Make tree with six iterations
# nx.draw(G2, with_labels = True)             #Uncomment to draw tree
# plt.show()
reg2 = len(
    list(DFS.DFS_reg(G2, startNode))
)  #Calculate number of nodes traversed to find solution without heuristic
print('Regular DFS traversed ', reg2, ' nodes to find the solution.')
heur2 = len(
    list(DFS.DFS_Heuristic(G2, startNode))
)  #Calculate number of nodes traversed to find solution with heuristic
print('Heuristic DFS traversed ', heur2, ' nodes to find the solution.')

#Run for three couple example
#Solution node can be found at depth 9
G3 = nx.DiGraph()
startNode = 'ABCabc|'
key = 0
G3 = makeNode_gotoCC(G3, startNode, key,
                     3)  #Create tree of depth one from root
depth3 = 8  #Depth of graph
G3 = makeGraph(G3, key, depth3, 3)  #Make tree with eight iterations
# nx.draw(G3, with_labels = True)             #Uncomment to draw tree
# plt.show()
reg3 = len(