gammagl.utils

gammagl.utils.calc_A_norm_hat

gammagl.utils.calc_gcn_norm

calculate GCN Normalization.

gammagl.utils.segment_softmax

segment softmax function.

gammagl.utils.sort_edge_index

Row-wise sorts edge_index.

gammagl.utils.coalesce

Row-wise sorts edge_index and removes its duplicated entries.

gammagl.utils.to_undirected

Converts the graph given by edge_index to an undirected graph such that \((j,i) \in \mathcal{E}\) for every edge \((i,j) \in \mathcal{E}\).

gammagl.utils.is_undirected

Returns True if the graph given by edge_index is undirected.

gammagl.utils.degree

Computes the (unweighted) degree of a given one-dimensional index tensor.

gammagl.utils.add_self_loops

Adds a self-loop \((i,i) \in \mathcal{E}\) to every node \(i \in \mathcal{V}\) in the graph given by edge_index.

gammagl.utils.remove_self_loops

Removes every self-loop in the graph given by edge_index, so that \((i,i) \not\in \mathcal{E}\) for every \(i \in \mathcal{V}\).

gammagl.utils.mask_to_index

Converts a mask to an index representation.

gammagl.utils.index_to_mask

Converts indices to a mask representation.

gammagl.utils.set_device

gammagl.utils.to_dense_batch

Given a sparse batch of node features \(\mathbf{X} \in \mathbb{R}^{(N_1 + \ldots + N_B) \times F}\) (with \(N_i\) indicating the number of nodes in graph \(i\)), creates a dense node feature tensor \(\mathbf{X} \in \mathbb{R}^{B \times N_{\max} \times F}\) (with \(N_{\max} = \max_i^B N_i\)).

gammagl.utils.k_hop_subgraph

Computes the induced subgraph of edge_index around all nodes in node_idx reachable within \(k\) hops.

gammagl.utils.negative_sampling

Samples random negative edges of a graph given by edge_index.

gammagl.utils.to_scipy_sparse_matrix

Converts a graph given by edge indices and edge attributes to a scipy sparse matrix.

gammagl.utils.read_embeddings

read pre trained and learned node embeddings

gammagl.utils.homophily

The homophily of a graph characterizes how likely nodes with the same label are near each other in a graph.