Ejemplo n.º 1
0
def load_datasets_nodelabel(names):
    """
    Loads the graph datasets DD, ENZYMES and NCI1, CiteSeer_Eval,CiteSeer_Train,Cora_Eval,Cora_Train and its labels.
    :params:    list of dataset names to load

    :return:    list of dataset names, list of loaded graphs for all datasets,
                node attributes for loaded graphs for all datasets
    """

    # load datasets
    datasets = []
    if "cs_eval" in names:
        datasets.append(Parser('datasets/CiteSeer_Eval'))
    if "cs_train" in names:
        datasets.append(Parser('datasets/CiteSeer_Train'))
    if "co_eval" in names:
        datasets.append(Parser('datasets/Cora_Eval'))
    if "co_train" in names:
        datasets.append(Parser('datasets/Cora_Train'))

    # convert datasets into lists graphs, labels
    datasets = [dataset.parse_all_graphs() for dataset in datasets]
    attr_sets = [[get_node_attributes(graph) for graph in graphs] for graphs in datasets]
    labels = [[get_node_labels(graph) for graph in graphs] for graphs in datasets]
    # attr_sets is a list of length n, where n is the number of datasets. Then attr[0] contains a list of all node attributes
    # for dataset 0. Thus attr[0][0] contains the actual node attribute matrix (X^0) for the graph of fataset 0.
    return names, datasets, attr_sets, labels
Ejemplo n.º 2
0
def load_dataset_nodelabel(name):
    """
    Loads one of the graph datasets DD, ENZYMES and NCI1, CiteSeer_Eval,CiteSeer_Train,Cora_Eval,Cora_Train and its labels.
    :params:    name of dataset to load

    :return:    list of loaded graphs, list of node features, list of labels
    """

    if "cs_train" == name:
        dataset = Parser('datasets/CiteSeer_Train')
    elif "cs_eval" == name:
        dataset = Parser('datasets/CiteSeer_Eval')
    elif "co_train" == name:
        dataset = Parser('datasets/Cora_Train')
    elif "co_eval" == name:
        dataset = Parser('datasets/Cora_Eval')
    else:
        raise ValueError(
            f"Given dataset name {name} is not a valid node dataset.")
    dataset = dataset.parse_all_graphs()
    # convert datasets into lists graphs, labels
    features = [get_node_attributes(graph) for graph in dataset]
    labels = [get_node_labels(graph) for graph in dataset]

    return dataset, features, labels
Ejemplo n.º 3
0
def load_dataset(name):
    """
    Loads and parses one dataset.
    :params:    name of dataset to load
    :return:    list of loaded graphs
    """

    dataset = Parser(os.path.join('datasets', name))
    graphs = dataset.parse_all_graphs()

    return graphs
Ejemplo n.º 4
0
def load_link_graph(name):
    """
    Loads the singular graph contained in the datasets Facebook and PPI.
    :params:    name of dataset to load

    :return:    singular graph
    """
    dataset = Parser(os.path.join('datasets', name))
    graphs = dataset.parse_all_graphs()

    return graphs[0]
Ejemplo n.º 5
0
def load_dataset(name):
    """
    Loads the graph dataset from file given a dataset name in form of a string.

    :param name:    string of dataset name
    :return:        loaded networkX graphs, graph labels
    """
    dataset = Parser(os.path.join('datasets', name))

    graphs = dataset.parse_all_graphs()
    labels = [get_graph_label(graph) for graph in graphs]

    return graphs, labels
Ejemplo n.º 6
0
def load_dataset_graph(name):
    """
    Loads the graph dataset from file given a dataset name in form of a string
    for graph classification.

    :param name:    string of dataset name
    :return:        loaded networkX graphs, graph labels
    """
    dataset = Parser(name)

    graphs = dataset.parse_all_graphs()
    labels = [get_graph_label(graph) for graph in graphs]

    return graphs, labels
Ejemplo n.º 7
0
def load_dataset_nodelabel(name):
    """
    Loads one of the graph datasets CiteSeet or Cora and its labels.
    :params:    name of dataset to load
    :return:    list of loaded graphs, list of node features, list of labels
    """

    dataset = Parser(os.path.join('datasets', name))
    graphs = dataset.parse_all_graphs()

    # convert datasets into lists graphs, labels
    features = [get_node_attributes(graph) for graph in graphs]
    labels = [get_node_labels(graph) for graph in graphs]

    return graphs, features, labels
Ejemplo n.º 8
0
def load_dataset_graph(name):
    """
    Loads the graph dataset from file given a dataset name in form of a string.

    :param name:    string of dataset name
    :return:        loaded networkX graphs, graph labels
    """
    if name == "Nci1":
        dataset = Parser("datasets/NCI1")
    elif name == "Enzymes":
        dataset = Parser("datasets/ENZYMES")
    else:
        raise ValueError(
            f"Given dataset name {name} is not a valid graph dataset.")

    dataset = dataset.parse_all_graphs()
    labels = [get_graph_label(graph) for graph in dataset]

    return dataset, labels