BNN-UPC / BNN-UPC/BNNetSimulator

TypeError: 'int' object is not subscriptable

Abierto
#3 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Jupyter Notebook
Estrellas
19
Forks
3
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

"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.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.