From fbafc66e40812fda82ad8ee832713ad1edc477eb Mon Sep 17 00:00:00 2001 From: Greg <11791585+elphick@users.noreply.github.com> Date: Sat, 25 Jan 2025 09:34:52 +0800 Subject: [PATCH] improved check before solve --- elphick/geomet/flowsheet/flowsheet.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/elphick/geomet/flowsheet/flowsheet.py b/elphick/geomet/flowsheet/flowsheet.py index a5341b9..fd618fc 100644 --- a/elphick/geomet/flowsheet/flowsheet.py +++ b/elphick/geomet/flowsheet/flowsheet.py @@ -15,6 +15,7 @@ import yaml from matplotlib import pyplot as plt from matplotlib.colors import ListedColormap, LinearSegmentedColormap +from networkx.algorithms.dag import is_directed_acyclic_graph from plotly.subplots import make_subplots from elphick.geomet import Sample @@ -306,6 +307,8 @@ def copy_without_stream_data(self): def solve(self): """Solve missing streams""" + assert is_directed_acyclic_graph(self.graph), "Graph is not a Directed Acyclic Graph (DAG), so cannot be solved." + # Check the number of missing mc's on edges in the network missing_count: int = sum([1 for u, v, d in self.graph.edges(data=True) if d['mc'] is None]) prev_missing_count = missing_count + 1 # Initialize with a value greater than missing_count