data

class cogdl.data.Graph(x=None, y=None, **kwargs)[source]

Bases: cogdl.data.data.BaseGraph

add_remaining_self_loops()[source]
clone()[source]
col_indices
col_norm()[source]
csr_subgraph(node_idx, keep_order=False)[source]
degrees()[source]
device
edge_attr
edge_index
edge_subgraph(edge_idx, require_idx=True)[source]
edge_types
edge_weight

Return actual edge_weight

eval()[source]
static from_dict(dictionary)[source]

Creates a data object from a python dictionary.

static from_pyg_data(data)[source]
in_norm
is_inductive()[source]
is_symmetric()[source]
keys

Returns all names of graph attributes.

local_graph()[source]
mask2nid(split)[source]
nodes()[source]
normalize(key='sym')[source]
num_classes
num_edges

Returns the number of edges in the graph.

num_features

Returns the number of features per node in the graph.

num_nodes
out_norm
padding_self_loops()[source]
random_walk(seeds, max_nodes_per_seed, restart_p=0.0)[source]
random_walk_with_restart(seeds, max_nodes_per_seed, restart_p=0.0)[source]
raw_edge_weight

Return edge_weight without __in_norm__ and __out_norm__, only used for SpMM

remove_self_loops()[source]
restore(key)[source]
row_indptr
row_norm()[source]
sample_adj(batch, size=-1, replace=True)[source]
set_asymmetric()[source]
set_symmetric()[source]
store(key)[source]
subgraph(node_idx, keep_order=False)[source]
sym_norm()[source]
test_nid
to_networkx()[source]
to_scipy_csr()[source]
train()[source]
train_nid
val_nid
class cogdl.data.Adjacency(row=None, col=None, row_ptr=None, weight=None, attr=None, num_nodes=None, types=None, **kwargs)[source]

Bases: cogdl.data.data.BaseGraph

add_remaining_self_loops()[source]
clone()[source]
col_norm()[source]
convert_csr()[source]
degrees(node_idx=None)[source]
device
edge_index
static from_dict(dictionary)[source]

Creates a data object from a python dictionary.

generate_normalization(norm='sym')[source]
get_weight(indicator=None)[source]

If indicator is not None, the normalization will not be implemented

is_symmetric()[source]
keys

Returns all names of graph attributes.

normalize_adj(norm='sym')[source]
num_edges
num_nodes
padding_self_loops()[source]
random_walk(seeds, length=1, restart_p=0.0)[source]
remove_self_loops()[source]
row_indptr
row_norm()[source]
row_ptr_v
set_symmetric(val)[source]
set_weight(weight)[source]
sym_norm()[source]
to_networkx(weighted=True)[source]
to_scipy_csr()[source]
class cogdl.data.Batch(batch=None, **kwargs)[source]

Bases: cogdl.data.data.Graph

A plain old python object modeling a batch of graphs as one big (dicconnected) graph. With cogdl.data.Data being the base class, all its methods can also be used here. In addition, single graphs can be reconstructed via the assignment vector batch, which maps each node to its respective graph identifier.

cumsum(key, item)[source]

If True, the attribute key with content item should be added up cumulatively before concatenated together.

Note

This method is for internal use only, and should only be overridden if the batch concatenation process is corrupted for a specific data attribute.

static from_data_list(data_list, class_type=None)[source]

Constructs a batch object from a python list holding cogdl.data.Data objects. The assignment vector batch is created on the fly. Additionally, creates assignment batch vectors for each key in follow_batch.

num_graphs

Returns the number of graphs in the batch.

class cogdl.data.Dataset(root, transform=None, pre_transform=None, pre_filter=None)[source]

Bases: torch.utils.data.dataset.Dataset

Dataset base class for creating graph datasets. See here for the accompanying tutorial.

Args:

root (string): Root directory where the dataset should be saved. transform (callable, optional): A function/transform that takes in an

cogdl.data.Data object and returns a transformed version. The data object will be transformed before every access. (default: None)
pre_transform (callable, optional): A function/transform that takes in
an cogdl.data.Data object and returns a transformed version. The data object will be transformed before being saved to disk. (default: None)
pre_filter (callable, optional): A function that takes in an
cogdl.data.Data object and returns a boolean value, indicating whether the data object should be included in the final dataset. (default: None)
static add_args(parser)[source]

Add dataset-specific arguments to the parser.

download()[source]

Downloads the dataset to the self.raw_dir folder.

edge_attr_size
get(idx)[source]

Gets the data object at index idx.

get_evaluator()[source]
get_loss_fn()[source]
max_degree
max_graph_size
num_classes

The number of classes in the dataset.

num_features

Returns the number of features per node in the graph.

num_graphs
process()[source]

Processes the dataset to the self.processed_dir folder.

processed_file_names

The name of the files to find in the self.processed_dir folder in order to skip the processing.

processed_paths

The filepaths to find in the self.processed_dir folder in order to skip the processing.

raw_file_names

The name of the files to find in the self.raw_dir folder in order to skip the download.

raw_paths

The filepaths to find in order to skip the download.

class cogdl.data.DataLoader(dataset, batch_size=1, shuffle=True, **kwargs)[source]

Bases: torch.utils.data.dataloader.DataLoader

Data loader which merges data objects from a cogdl.data.dataset to a mini-batch.

Args:

dataset (Dataset): The dataset from which to load the data. batch_size (int, optional): How may samples per batch to load.

(default: 1)
shuffle (bool, optional): If set to True, the data will be
reshuffled at every epoch (default: True)
static collate_fn(batch)[source]
get_parameters()[source]
record_parameters(params)[source]
class cogdl.data.MultiGraphDataset(root=None, transform=None, pre_transform=None, pre_filter=None)[source]

Bases: cogdl.data.dataset.Dataset

get(idx)[source]

Gets the data object at index idx.

len()[source]
max_degree
max_graph_size
num_classes

The number of classes in the dataset.

num_features

Returns the number of features per node in the graph.

num_graphs
cogdl.data.batch_graphs(graphs)[source]