Esempio n. 1
0
    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])
Esempio n. 2
0
File: graph.py Progetto: yk/dvc
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)
Esempio n. 3
0
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))