Пример #1
0
def write_cycle(filename, graph, cycle, directed):
    n = len(graph)
    weight = [[float('inf')] * n for _ in range(n)]
    for r in range(1, len(c)):
        weight[c[r-1]][c[r]] = r
        if not directed:
            weight[c[r]][c[r-1]] = r
    write_graph(filename, graph, arc_label=weight, directed=directed)
Пример #2
0
def write_cycle(filename, graph, cycle, directed):
    n = len(graph)
    weight = [[float('inf')] * n for _ in range(n)]
    for r in range(1, len(c)):
        weight[c[r - 1]][c[r]] = r
        if not directed:
            weight[c[r]][c[r - 1]] = r
    write_graph(filename, graph, arc_label=weight, directed=directed)
Пример #3
0
def write_cycle(filename, graph, cycle, directed):
    """Write an eulerian tour in DOT format

       :param filename: the file to be written in DOT format
       :param graph: graph in listlist format, cannot be listdict
       :param bool directed: describes the graph
       :param cycle: tour as a vertex list
       :returns: nothing
       :complexity: `O(|V|^2 + |E|)`
    """
    n = len(graph)
    weight = [[float('inf')] * n for _ in range(n)]
    for r in range(1, len(cycle)):
        weight[cycle[r - 1]][cycle[r]] = r
        if not directed:
            weight[cycle[r]][cycle[r - 1]] = r
    write_graph(filename, graph, arc_label=weight, directed=directed)
Пример #4
0
def write_cycle(filename, graph, cycle, directed):
    """Write an eulerian tour in DOT format

       :param filename: the file to be written in DOT format
       :param graph: graph in listlist format, cannot be listdict
       :param bool directed: describes the graph
       :param cycle: tour as a vertex list
       :returns: nothing
       :complexity: `O(|V|^2 + |E|)`
    """
    n = len(graph)
    weight = [[float('inf')] * n for _ in range(n)]
    for r in range(1, len(cycle)):
        weight[cycle[r-1]][cycle[r]] = r
        if not directed:
            weight[cycle[r]][cycle[r-1]] = r
    write_graph(filename, graph, arc_label=weight, directed=directed)