pyotc.otc_backend.graph package

Submodules

pyotc.otc_backend.graph.utils module

pyotc.otc_backend.graph.utils.adj_to_trans(A)[source]

Converts an adjacency matrix into a row-stochastic transition matrix.

Parameters:

A (np.ndarray) – Adjacency matrix of shape (n, n).

Returns:

Transition matrix of shape (n, n), where each row sums to 1.

Return type:

np.ndarray

pyotc.otc_backend.graph.utils.get_01_cost(V1, V2)[source]

Computes a binary cost matrix between node features of two graphs based on inequality.

Given two vectors representing features of nodes from two graphs, this function returns a binary cost matrix where each entry is 1 if the corresponding features differ, and 0 otherwise.

Parameters:
  • V1 (np.ndarray) – Feature vector for nodes in graph 1, of shape (n1,).

  • V2 (np.ndarray) – Feature vector for nodes in graph 2, of shape (n2,).

Returns:

Binary cost matrix of shape (n1, n2), where entry (i, j) is 1

if V1[i] != V2[j], else 0.

Return type:

np.ndarray

pyotc.otc_backend.graph.utils.get_degree_cost(A1, A2)[source]

Computes a cost matrix based on squared degree differences between nodes.

Parameters:
  • A1 (np.ndarray) – First adjacency matrix of shape (n1, n1).

  • A2 (np.ndarray) – Second adjacency matrix of shape (n2, n2).

Returns:

Cost matrix of shape (n1, n2) with squared degree differences.

Return type:

cost_mat (np.ndarray)

pyotc.otc_backend.graph.utils.get_sq_cost(V1, V2)[source]

Computes a cost matrix based on squared differences between node features of two graphs.

Given two vectors representing node features from two graphs, this function computes a cost matrix where each entry (i, j) is the squared difference between the i-th feature in graph 1 and the j-th feature in graph 2.

Parameters:
  • V1 (np.ndarray) – Feature vector for nodes in graph 1, of shape (n1,).

  • V2 (np.ndarray) – Feature vector for nodes in graph 2, of shape (n2,).

Returns:

Cost matrix of shape (n1, n2), where entry (i, j) = (V1[i] - V2[j]) ** 2.

Return type:

np.ndarray

pyotc.otc_backend.graph.utils.weight(x)[source]

Normalizes a vector into a probability distribution.

Parameters:

x (np.ndarray) – Input vector.

Returns:

Normalized vector such that the sum is 1.

Return type:

np.ndarray

Module contents

Routines producing stationary processes on graphs