Ejemplo n.º 1
0
def build_map(network_config):
    map_graph = MapGraph()
    for n in network_config['networks']:
        fname = n[0]
        options = n[1:]
        map_graph.append_from_file(fname, options)
    return map_graph
Ejemplo n.º 2
0
def read_graph_from_text(file_path, conn):
    """Read a text file created using write_graph_to_text into a MapGraph.

    Parameters
    ----------
    file_path : string
      Full specification of the text file's name, relative to the current
      directory.

    conn : CoCoTools ConGraph
      ConGraph associated with the saved MapGraph.

    Returns
    -------
    mapp : CoCoTools MapGraph
      MapGraph with all the edges saved in the text file.
    """
    mapp = MapGraph(conn)
    tp_edges = []
    with open(file_path) as f:
        for line in f:
            source, target, attributes = line.split()
            tp = attributes['TP']
            if tp:
                # We can't add the edge right away, because it depends
                # on other edges being in the graph.
                tp_edges.append((source, target, tp))
            else:
                rc = attributes['RC']
                pdc = attributes['PDC']
                mapp.add_edge(source, target, rc=rc, pdc=pdc)
    while tp_edges:
        source, target, tp = tp_edges.pop(0)
        try:
            mapp.add_edge(source, target, tp=tp)
        except MapGraphError:
            tp_edges.append((source, target, tp))
    return mapp
Ejemplo n.º 3
0
def build_map(network_config):
    map_graph = MapGraph()
    for n in network_config['networks']:
        map_graph.append_from_file(n)
    return map_graph
Ejemplo n.º 4
0
def main():
    data_files = sys.argv[1:]
    map_graph = MapGraph.read_map(data_files)
    generate_svg(map_graph, MAP_FRAME, SVG_SCALE)