I have a simple dot file with the list of nodes and edges. Each node is the network device. Devices connected to each other through interfaces, so i used head and tail labels as interface name:
"172.16.3.205" -- "172.16.3.178" [taillabel="27", headlabel="1:16"];
I'm trying to find all simple paths between 2 given nodes and get list of nodes and correct interfaces:
import networkx as nx
G=nx.read_dot('out.gv')
for path in nx.all_simple_paths(G,source='172.16.3.178',target='172.16.3.207'):
path = G.subgraph(path)
path.edges(data=True)
and I'm getting something like this:
[('172.16.3.178', '172.16.3.205', {'taillabel': '"27"', 'headlabel': '"1:16"'}), ('172.16.3.203', '172.16.3.205', {'taillabel': '"27"', 'headlabel': '"26"'}), ('172.16.3.203', '172.16.3.207', {'taillabel': '"26"', 'headlabel': '"28"'})]
'172.16.3.178' switched with '172.16.3.205'. Is there a way to save order?
P.S. Actually, I don't really need to draw a graph. I just need a list (or something more useful) of nodes with interfaces that involved in path like this: [('172.16.3.178', {'1:16'}), ('172.16.3.203', {'27', '26'}), ('172.16.3.205', {'26', '27'}), ('172.16.3.207', {'28'})]