aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2022-11-20 11:09:00 +0100
committerDimitri Staessens <dimitri@ouroboros.rocks>2022-11-20 11:10:01 +0100
commit91a206520d99eaabb21f6ba2bffc38445a697e9e (patch)
tree02e8228a939a7cb12da45798a1f7fd857254297c
parent9d4efe67c01c8c5a3f3bd1ee71af8b7c03021a18 (diff)
downloadrumba-91a206520d99eaabb21f6ba2bffc38445a697e9e.tar.gz
rumba-91a206520d99eaabb21f6ba2bffc38445a697e9e.zip
visualizer: Offset layers at same rank
Layers at the same rank will now be slightly offset. Increased line width for adjacencies. Added igraph and plotly packages to extra requirements. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
-rwxr-xr-xrumba/visualizer.py38
-rwxr-xr-xsetup.py3
2 files changed, 36 insertions, 5 deletions
diff --git a/rumba/visualizer.py b/rumba/visualizer.py
index f8c18e6..4e7aa7f 100755
--- a/rumba/visualizer.py
+++ b/rumba/visualizer.py
@@ -210,7 +210,7 @@ def _create_system_coords(network):
edges = _create_system_graph(network)
g = ig.Graph(edges, directed=False)
- layout = g.layout('drl', dim=2)
+ layout = g.layout('fr', dim=2)
for system in network['_systems']:
n = system['node']
@@ -240,11 +240,29 @@ def _get_ipcps_by_rank(ipcps, rank):
return [ipcp for ipcp in ipcps if ipcp['rank'] == rank]
+def _get_ipcps_by_layer(network, layer):
+ return [ipcp for ipcp in network['_ipcps'] if ipcp['layer'] == layer]
+
+
+def _get_rank_for_layer(network, layer):
+ for ipcp in network['_ipcps']:
+ if ipcp['layer'] == layer:
+ return ipcp['rank']
+
+ return 0
+
+
+def _get_layers_by_rank(network, rank):
+ return [layer for layer in network['layers']
+ if _get_rank_for_layer(network, layer) == rank]
+
+
def _create_ipcp_coords(network, radius):
"""
Create 3d coordinates for IPCPs based on the system layout
"""
- height = 1
+ height = 1.0
+ max_rank = 0
for system in network['_systems']:
ipcps = _get_ipcps_for_system(network, system)
@@ -264,6 +282,18 @@ def _create_ipcp_coords(network, radius):
new_y = y + radius * cos((m/n) * pi)
ipcp['coords'] = (new_x, new_y, rank * height)
m += 1
+ max_rank = max(max_rank, rank)
+
+ for rank in range(max_rank + 1):
+ layers = _get_layers_by_rank(network, rank)
+ increment = height / (3 / 2 * len(layers))
+ offset = 0
+ for layer in layers:
+ ipcps = _get_ipcps_by_layer(network, layer)
+ for ipcp in ipcps:
+ (x, y, z) = ipcp['coords']
+ ipcp['coords'] = (x, y, z + offset)
+ offset += increment
def _create_ipcp_graph_data(network):
@@ -370,7 +400,7 @@ def draw_network(network, name='Ouroboros network'):
line=dict(color=colors,
colorscale='Viridis',
dash='solid',
- width=2),
+ width=4),
hoverinfo='none'
)
@@ -383,7 +413,7 @@ def draw_network(network, name='Ouroboros network'):
mode='lines',
line=dict(color=colors,
colorscale='Viridis',
- dash='dashdot',
+ dash='solid',
width=1),
hoverinfo='none'
)
diff --git a/setup.py b/setup.py
index 6c4fd62..058a26c 100755
--- a/setup.py
+++ b/setup.py
@@ -31,6 +31,7 @@ setuptools.setup(
'enum34; python_version<"3.0"'
],
extras_require={'NumpyAcceleration': ['numpy'],
- 'graphs' : ['pydot']},
+ 'graphs': ['pydot'],
+ 'visualizer': ['igraph', 'plotly']},
scripts=['tools/rumba-access']
)