def _check_cyclic_graph(graph): import networkx as nx from dvc.exceptions import CyclicGraphError cycles = list(nx.simple_cycles(graph)) if cycles: raise CyclicGraphError(cycles[0])
def check_acyclic(graph): import networkx as nx from dvc.exceptions import CyclicGraphError cycle = next(nx.simple_cycles(graph), None) if cycle: raise CyclicGraphError(cycle)
def check_acyclic(graph): import networkx as nx from dvc.exceptions import CyclicGraphError try: edges = nx.find_cycle(graph, orientation="original") except nx.NetworkXNoCycle: return stages = set() for from_node, to_node, _ in edges: stages.add(from_node) stages.add(to_node) raise CyclicGraphError(list(stages))