How can I find all the paths between its source and destination using thread (for source_node) and thread (for other_nodes) and queue sharing in Python (every node send mesg (path content) for his neighbors until find destination et. Finaly visualising path created step by step (result find and animate visialisation path in graph from source to destination), but childs nodes not send data for his parent. thanks
from typing import List
import networkx as nx
import matplotlib.pyplot as plt
import pickle
from queue import Queue
import threading
import time
import queue
from random import randint
#-----------------------------Graph Topologie-------------------------------------------------------------
G = nx.Graph()
G.add_node(0, pos=(10, 8))
G.add_node(1, pos=(8, 11))
G.add_node(2, pos=(8, 8))
G.add_node(3, pos=(8, 6))
G.add_node(4, pos=(6, 11))
G.add_node(5, pos=(6, 6))
G.add_node(6, pos=(8, 4))
G.add_edge(0, 1,weight=1)
G.add_edge(0, 2,weight=1)
G.add_edge(0, 3,weight=1)
G.add_edge(1, 4,weight=1)
G.add_edge(2, 4,weight=1)
G.add_edge(2, 5,weight=1)
G.add_edge(3, 5,weight=1)
G.add_edge(4, 6,weight=1)
G.add_edge(5, 6,weight=1)
pos = nx.get_node_attributes(G, 'pos')
plt.title('Network topology')
nx.draw(G, pos, with_labels=True)
plt.savefig("graph.png") # save topology to graph.png
#plt.show()
#-------------------------------------------------------------------------
q=Queue()
# u nodes intermediate
def Other_Node(graph, u, d, visited, path):
# Mark the current node as visited and store in path
visited[u] = True
path.append(u)
# If current vertex is same as destination, then print
# current path[]
if u == d:
print(path)
else:
# If current vertex is not destination
# Recur for all the neighbors to this vertex
for i in list(graph.neighbors(u)):
if visited[i] == False:
Other_Node(graph,i, d, visited, path)
# Remove current vertex from path[] and mark it as unvisited
path.pop()
visited[u] = False
#--------------------------------------------------------------------
# Prints all paths from 's' to 'd'
def Node_Source(graph, s, d):
# Mark all the vertices as not visited
visited = [False] * (len(list(graph.nodes())))
# Create an array to store paths
path = []
time.sleep(1)
# Call the recursive helper function to print all paths
Other_Node(graph,s, d, visited, path)
s = int(input('entrer le noeud source ', ))
d = int(input('entrer le noeud destinataire ', ))
print("Following are all different paths from %d to %d :" % (s, d))
#Node_Source(G,s, d)
t1 = threading.Thread(target = Node_Source, args = (G,s,d, ))
for i in list(G.nodes()-{s}):
t2 = threading.Thread(target = Other_Node, args = (G,s,d, ))
t2.start()