BNN-UPC / BNN-UPC/BNNetSimulator
TypeError: 'int' object is not subscriptable
- Dominant language
- Jupyter Notebook
- Stars
- 19
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
"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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.