def match_nodes(var_id_dict, node_label=None):
    """Match a collection of nodes by their id.

    Parameters
    ----------
    var_id_dict : dict
        Dictionary whose keys are names of the variables to use for
        the matched nodes and whose values are the ids of the nodes
        to match
    label : str
        Label of the nodes to match
    """
    node_label_str = ""
    if node_label:
        node_label_str = ":{}".format(node_label)

    query =\
        "MATCH " +\
        ", ".join("({}{} {{ id : '{}'}}) ".format(
            var_name, node_label_str, node_id)
            for var_name, node_id in var_id_dict.items()) + " "
    return query