def add_nodes(nodes, graph):
    """Add the nodes to the graph and return a dictionary which maps ids as read
    from the csv data files to the ids as assigned by igraph.
    """
    graph.add_vertices(nodes)
    idmap = {v['name']: v.index for v in graph.vs}
    return idmap