def get_node_id(edge, node_type):
    """
    returns the source or target node id of an edge, depending on the
    node_type given.
    """
    assert node_type in ('source', 'target')
    _, node_id_str = edge.attrib[node_type].split('.')  # e.g. //@nodes.251
    return int(node_id_str)