BNN-UPC / BNN-UPC/BNNetSimulator

TypeError: 'int' object is not subscriptable

Aperta
#3 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Jupyter Notebook
Stelle
19
Fork
3
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

"Hello, can the source and destination nodes not be set manually in the function that generates the routing scheme? If the source and destination nodes are set manually:"
def generate_routing(G, routing_file):
source_nodes = [0, 10, 16]
destination_nodes = [26, 28, 33, 32, 23, 22]
k = 3
with open(routing_file, "w") as r_fd:
for src in source_nodes:
for dst in destination_nodes:
if src != dst:
paths_generator = nx.shortest_simple_paths(G, source=src, target=dst)
for i, path in enumerate(paths_generator):
if i >= k:
break
path_str = ','.join(str(x) for x in path)
r_fd.write(path_str + "\n")
It will produce the following error:
Traceback (most recent call last):
File "/usr/src/NetSimulator/Simulate.py", line 776, in
if (prepare_simulation(line.strip(),ctr)!=0):
File "/usr/src/NetSimulator/Simulate.py", line 606, in prepare_simulation
process_routing_file(G,routing_file,ctr)
File "/usr/src/NetSimulator/Simulate.py", line 369, in process_routing_file
saveRouting(G,path_matrix,routing_path)
File "/usr/src/NetSimulator/Simulate.py", line 326, in saveRouting
s0 = path[0]
TypeError: 'int' object is not subscriptable
But if the code is like the following, it will not produce an error:
def generate_routing(G, routing_file):
source_nodes = [0, 10, 16]
destination_nodes = [26, 28, 33, 32, 23, 22]
k = 3
with open(routing_file, "w") as r_fd:
for src in G:
for dst in G:
if src != dst:
paths_generator = nx.shortest_simple_paths(G, source=src, target=dst)
for i, path in enumerate(paths_generator):
if i >= k:
break
path_str = ','.join(str(x) for x in path)
r_fd.write(path_str + "\n")
Can you provide more context or specify the code in question? This will help in identifying the issue.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.