BNN-UPC / BNN-UPC/BNNetSimulator

TypeError: 'int' object is not subscriptable

Offen
#3 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Jupyter Notebook
Sterne
19
Forks
3
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.