Skip to content
Snippets Groups Projects
Commit 6d109ca9 authored by NGUYEN Do Duc Anh's avatar NGUYEN Do Duc Anh
Browse files

update weight for nice topology generator

parent 774ef476
No related branches found
No related tags found
No related merge requests found
...@@ -39,8 +39,16 @@ class GraphGenerator: ...@@ -39,8 +39,16 @@ class GraphGenerator:
# Add connections # Add connections
G.add_edges_from(connections) G.add_edges_from(connections)
# Generate positions using spring layout for u, v in G.edges:
positions = nx.spring_layout(G, scale=scale) if "pc_" in u and "ui_" in v or "pc_" in v and "ui_" in u:
G[u][v]["weight"] = 27.0 # Strong pull
elif "ub_" in v and "ui_" in u or "ui_" in v and "ub_" in u:
G[u][v]["weight"] = 3.0 # Strong pull
else:
G[u][v]["weight"] = 1.0 # Default pull
# Generate positions with spring layout using weights
positions = nx.spring_layout(G, scale=scale, weight='weight', k=1.0 / scale, pos=None)
# Convert positions to integers for GNS3 # Convert positions to integers for GNS3
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment