From c08ef7b956c3a04fee975bd7264e9e76a41e2af5 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sun, 20 Nov 2022 12:08:32 +0100 Subject: visualizer: Fix overlapping register lines This fixes overlapping lines if an IPCP at rank N is registered at multiple lower layers. Also updates the example to a network that is feasible. Signed-off-by: Dimitri Staessens --- rumba/visualizer.py | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/rumba/visualizer.py b/rumba/visualizer.py index 4e7aa7f..a2f35cb 100755 --- a/rumba/visualizer.py +++ b/rumba/visualizer.py @@ -34,22 +34,22 @@ def get_default_test_network(): 'bottom_layer1': { 'type': 'eth-dix', 'nodes': list(range(5)), - 'edges': [(0, 1), (0, 2), (0, 3), (1, 3), (2, 3), (1, 4), (2, 4)] + 'edges': [(0, 1), (0, 2), (0, 3), (0, 4), (1, 3), (2, 3), (1, 4), (2, 4)] }, 'bottom_layer2': { 'type': 'eth-llc', 'nodes': list(range(4, 8)), - 'edges': [(4, 5), (5, 6), (6, 7), (4, 7)] + 'edges': [(4, 5), (5, 6), (5, 7), (6, 7), (4, 7)] }, 'medium_layer': { 'type': 'unicast', 'nodes': [0, 2, 4, 5, 7], - 'edges': [(0, 2), (0, 4), (4, 5), (5, 7), (2, 5), (4, 7)] + 'edges': [(0, 2), (0, 4), (4, 5), (5, 7), (2, 4), (4, 7)] }, 'top_layer': { 'type': 'unicast', - 'nodes': [0, 7], - 'edges': [(0, 7)] + 'nodes': [0, 3, 6, 7], + 'edges': [(0, 7), (0, 3), (6, 7)] } }, 'registrations': { @@ -58,7 +58,9 @@ def get_default_test_network(): 'bottom_layer2': [4, 5, 7] }, 'top_layer': { - 'medium_layer': [0, 7] + 'medium_layer': [0, 7], + 'bottom_layer1': [0, 3], + 'bottom_layer2': [6, 7] } } } @@ -267,21 +269,16 @@ def _create_ipcp_coords(network, radius): for system in network['_systems']: ipcps = _get_ipcps_for_system(network, system) ranks = _get_ranks_for_ipcps(ipcps) - for rank in ranks: - ri = _get_ipcps_by_rank(ipcps, rank) - n = len(ri) - m = 1 - for ipcp in ri: - if n == 1: - x, y = system['coords'] - ipcp['coords'] = (x, y, rank * height) - continue - x = system['coords'][0] - y = system['coords'][1] - new_x = x + radius * sin((m/n) * pi) - new_y = y + radius * cos((m/n) * pi) - ipcp['coords'] = (new_x, new_y, rank * height) - m += 1 + n = len(ipcps) + m = 1 + for ipcp in ipcps: + rank = ipcp['rank'] + x = system['coords'][0] + y = system['coords'][1] + new_x = x + radius * sin((m/n) * pi) + 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): -- cgit v1.2.3