def get_ids_from_nodes(node_prefix, nodes):
    """
    Take a list of nodes from G and returns a list of the ids of only the nodes with the given prefix.

    param node_prefix: prefix for the nodes to keep.
    type node_prefix: str.

    param nodes: list of nodes from G.
    type nodes: [(str, int)].
    """
    return map(lambda pair: pair[1], filter(lambda pair: pair[0] == node_prefix, nodes))