Skip to content
Snippets Groups Projects

Stats

Merged
pmagrequested to merge
stats into master
5 files
+ 130
1
Compare changes
  • Side-by-side
  • Inline

Files

@@ -1256,6 +1256,31 @@ class Network(nx.MultiDiGraph):
return nx.is_tree(network_view)
# *************************************************************************
# *************************************************************************
def has_selected_antiparallel_arcs(self) -> bool:
"Returns True if any two nodes have selected arcs in both directions."
return len(self.find_selected_antiparallel_arcs()) != 0
# *************************************************************************
# *************************************************************************
def find_selected_antiparallel_arcs(self) -> list:
"""Returns True if any two nodes have (selected) forward and reverse arcs."""
# check the existence of forward and reverse arcs in the same segment
arcs = [ # get the arcs selected
arc_key[0:2]
for arc_key in self.edges(keys=True)
if True in self.edges[arc_key][Network.KEY_ARC_TECH].options_selected
]
arcs = [ # get the selected arcs that exist both ways
arc_key
for arc_key in arcs
if (arc_key[1], arc_key[0]) in arcs
]
return arcs
# *****************************************************************************
# *****************************************************************************
Loading