def _write_stop_to_stop_network_edges(net, file_name, data=True, fmt=None):
if fmt is None:<EOL><INDENT>fmt = "<STR_LIT>"<EOL><DEDENT>if fmt == "<STR_LIT>":<EOL><INDENT>if data:<EOL><INDENT>networkx.write_edgelist(net, file_name, data=True)<EOL><DEDENT>else:<EOL><INDENT>networkx.write_edgelist(net, file_name)<EOL><DEDENT><DEDENT>elif fmt == "<STR_LIT>":<EOL><INDENT>with open(file_name, '<STR_LIT:w>') as f:<EOL><INDENT>edge_iter = net.edges_iter(data=True)<EOL>_, _, edg_data = next(edge_iter)<EOL>edg_data_keys = list(sorted(edg_data.keys()))<EOL>header = "<STR_LIT:;>".join(["<STR_LIT>", "<STR_LIT>"] + edg_data_keys)<EOL>f.write(header)<EOL>for from_node_I, to_node_I, data in net.edges_iter(data=True):<EOL><INDENT>f.write("<STR_LIT:\n>")<EOL>values = [str(from_node_I), str(to_node_I)]<EOL>data_values = []<EOL>for key in edg_data_keys:<EOL><INDENT>if key == "<STR_LIT>":<EOL><INDENT>route_I_counts_string = str(data[key]).replace("<STR_LIT:U+0020>", "<STR_LIT>")[<NUM_LIT:1>:-<NUM_LIT:1>]<EOL>data_values.append(route_I_counts_string)<EOL><DEDENT>else:<EOL><INDENT>data_values.append(str(data[key]))<EOL><DEDENT><DEDENT>all_values = values + data_values<EOL>f.write("<STR_LIT:;>".join(all_values))<EOL><DEDENT><DEDENT><DEDENT>
Write out a network

Parameters
----------
net: networkx.DiGraph
base_name: str
    path to the filename (without extension)
data: bool, optional
    whether or not to write out any edge data present
fmt: str, optional
    If "csv" write out the network in csv format.