mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 11:23:10 +00:00
suppression des doubles liens
This commit is contained in:
parent
c06d710d3c
commit
684134f351
2 changed files with 13 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
||||||
{% block graph_dot %}
|
{% block graph_dot %}
|
||||||
strict digraph {
|
digraph {
|
||||||
graph [label="TOPOLOGIE DU RÉSEAU", labelloc=t, fontsize=40];
|
graph [label="TOPOLOGIE DU RÉSEAU", labelloc=t, fontsize=40];
|
||||||
node [fontname=Helvetica fontsize=8 shape=plaintext];
|
node [fontname=Helvetica fontsize=8 shape=plaintext];
|
||||||
edge[arrowhead=none];
|
edge[arrowhead=none];
|
||||||
|
|
|
@ -1071,19 +1071,21 @@ def recursive_switchs(switch_start, switch_before, detected):
|
||||||
:param switch_before: the switch that you come from. None if switch_start is the first one
|
:param switch_before: the switch that you come from. None if switch_start is the first one
|
||||||
:param detected: list of all switchs already visited. None if switch_start is the first one
|
:param detected: list of all switchs already visited. None if switch_start is the first one
|
||||||
:return: A list of all the links found and a list of all the switchs visited"""
|
:return: A list of all the links found and a list of all the switchs visited"""
|
||||||
|
detected.append(switch_start)
|
||||||
links_return=[] # list of dictionaries of the links to be detected
|
links_return=[] # list of dictionaries of the links to be detected
|
||||||
for port in switch_start.ports.filter(related__isnull=False): # Ports that are related to another switch
|
for port in switch_start.ports.filter(related__isnull=False): # create links to every switchs below
|
||||||
if port.related.switch != switch_before and port.related.switch != port.switch: # Not the switch that we come from, not the current switch
|
if port.related.switch != switch_before and port.related.switch != port.switch and port.related.switch not in detected: # Not the switch that we come from, not the current switch
|
||||||
links = { # Dictionary of a link
|
links = { # Dictionary of a link
|
||||||
'depart':switch_start.id,
|
'depart':switch_start.id,
|
||||||
'arrive':port.related.switch.id
|
'arrive':port.related.switch.id
|
||||||
}
|
}
|
||||||
|
links_return.append(links) # Add current and below levels links
|
||||||
|
|
||||||
|
for port in switch_start.ports.filter(related__isnull=False): # go down on every related switchs
|
||||||
if port.related.switch not in detected: # The switch at the end of this link has not been visited
|
if port.related.switch not in detected: # The switch at the end of this link has not been visited
|
||||||
links_down, detected = recursive_switchs(port.related.switch, switch_start, detected) # explore it and get the results
|
links_down, detected = recursive_switchs(port.related.switch, switch_start, detected) # explore it and get the results
|
||||||
for link in links_down: # Add the non empty links to the current list
|
for link in links_down: # Add the non empty links to the current list
|
||||||
if link:
|
if link:
|
||||||
links_return.append(link)
|
links_return.append(link)
|
||||||
links_return.append(links) # Add current and below levels links
|
|
||||||
detected.append(switch_start) # This switch is considered detected
|
|
||||||
return (links_return, detected)
|
return (links_return, detected)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue