def write_edge_csv(edges, fname, delim=';'):
    """
    Write a three-field csv file formatted as
    (cleft_id, presyn_segid, postsyn_segid).
    """
    with open(fname, 'w+') as f:
        for cleft_id, presyn_id, postsyn_id in edges:
            content = delim.join(map(str, (cleft_id, presyn_id, postsyn_id)))
            f.write(f'{content}\n')
