vtx_color (array_like, optional) – All valid type for np.asarray() is acceptable, including
torch.Tensor on cpu. If None, this function will invoke
thgsp.alg.dsatur() silently.
The oversampled bipartite graph approximation method proposed in [1]
Parameters:
A (SparseTensor) – The adjacent matrix of graph.
lc (int) – The ordinal of color marking the boundary such that all nodes with a smaller color
ordinal are grouped into the low-pass channel while those with a larger color
ordinal are in the high-pass channel.
vtx_color (iter) – The graph coloring result
Returns:
bptG (lil_matrix) – The oversampled graph(with additional nodes)
beta (np.ndarray)
append_nodes (np.ndarray) – The indices of those appended nodes
This algorithm does NOT guarantee bipartite output graphs in some cases.
Nevertheless, the output graphs are
almost bipartite,i.e., only a few edges violate the bipartiteness. One can use
is_bipartite_fix() to fix the output under such circumstances.
Parameters:
A (Tensor(N x N)) – N is the number of graph nodes
M (int, optional) – The number of bipartite graphs to learn
alpha (float,optional) – The parameter which controls the orthogonality among learnt bipartite graphs
metric (str,optional) – The error metric between the learned bipartite graphs and the original graph
cut_edge (bool,optional) – If True, cut the edges in the learned bipartite graphs that not exist in the
original graph
B0 (Tensor,optional) – The initialization of B
convergence_marker (float,optional) – the procedure converges if the error between B and A < this value
check_step (int,optional) – the step interval to display iteration information
AMFS bipartite approximation for graph wavelet signal processing [3].
Parameters:
A (SparseTensor) – The adjacency matrix.
Sigma (scipy.spmatrix, optional) – The covariance matrix specified by the Laplacian matrix L. If None,
\(\Sigma^{-1}=L+\delta I\)
level (int, optional) – The number of bipartite subgraphs, i.e., the decomposition level. If None,
\(level=\lceil log_2( \mathcal{X}) \rceil\), where \(\mathcal{X}\) is
the chromatic number of A.
delta (float, optional) – \(1/\delta\) is interpreted as the variance of the DC compnent. Refer to
[4] for more details.
thresh_kld (float, optional) – Threshold of Kullback-Leibler divergence to perform AMFS decomposition.
priority (bool,optional) – If True, KLD holds priority.
Generate a (2^M,N) bool mask tensor to indicate which
channel(color group) one node belongs to. All channels have disjoint node
sets and hence the sum along the channel dimension returns a all-one(True)
(N,) tensor.
Note
This function is a common approach to generate channel mask for multi-channel
wavelet filterbank. Either coloring or numerical based bipartite approximation
algorithm can employ this function.
Parameters:
beta (BoolTensor(N,M)) – Bipartite partition indicator tensor. N and M are the node and
bipartite subgraph numbers, respectively.
Returns:
mask (BoolTensor(2**M,N)) – The indices of True in i-th row are nodes whose signal will be
kept in i-th channel.
beta_dist (array(2**M,M))) – An array, see the doc of thgsp.filters.QmfCore for the details.
Actually, beta2channel_group is more exact since “color” here is not
exact graph coloring. However we can take it as an approximation of graph
coloring.
Parameters:
beta (BoolTensor(N,M)) – Bipartite partition indicator tensor. N and M are the node and
bipartite subgraph numbers, respectively.
th (bool, optional) – If True, the value of returned dict is Tensor otherwise array.
Returns:
color_group (dict) – color_group[i] is a LongTensor (or array) of node indices
colored with i-th color.
Generate a bool mask matrix which can extract a bipartite subgraph from any graph
(represented by a matrix) .
Parameters:
bt (BoolTensor, array) – The indicator of two bipartite sets. All nodes within a same bipartite set is
characterized by a same bool value, e.g.,True. Shape: (N,), N is the number
of graph nodes.
Check if a graph is bipartite using BFS-based 2-color coloring and
furthermore can fix a graph to a bipartite one by deleting edges bridging
two nodes colored with a same color.
Parameters:
A (Tensor) – The adjacency matrix
fix_flag (bool,optional) – If True, fix A to a bipartite graph by zeroing some elements in-place.
Returns:
flag (bool) – If True, the returned adjacency matrix represents a bipartite graph
vxt_color (list) – A list recording the vertex colors which are all 1 or 0.
A (Tensor) – The adjacency matrix of returned graph.