示例#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])
示例#2
0
文件: graph.py 项目: 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)
示例#3
0
文件: graph.py 项目: wegamekinglc/dvc
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))