return (real) nlevel0 - 1;
}
-int SparseMatrix_connectedQ(SparseMatrix A0){
- int root = 0, nlevel, *levelset_ptr = NULL, *levelset = NULL, *mask = NULL, connected;
- SparseMatrix A = A0;
-
- if (!SparseMatrix_is_symmetric(A, TRUE)){
- if (A->m != A->n) return FALSE;
- A = SparseMatrix_symmetrize(A, TRUE);
- }
-
- SparseMatrix_level_sets(A, root, &nlevel, &levelset_ptr, &levelset, &mask, TRUE);
- connected = (levelset_ptr[nlevel] == A->m);
-
- FREE(levelset_ptr);
- FREE(levelset);
- FREE(mask);
- if (A != A0) SparseMatrix_delete(A);
-
- return connected;
-}
-
-
void SparseMatrix_decompose_to_supervariables(SparseMatrix A, int *ncluster, int **cluster, int **clusterp){
/* nodes for a super variable if they share exactly the same neighbors. This is know as modules in graph theory.
We work on columns only and columns with the same pattern are grouped as a super variable
int SparseMatrix_has_diagonal(SparseMatrix A);
SparseMatrix SparseMatrix_scaled_by_vector(SparseMatrix A, real *v, int apply_to_row);
SparseMatrix SparseMatrix_make_undirected(SparseMatrix A);/* make it strictly low diag only, and set flag to undirected */
-int SparseMatrix_connectedQ(SparseMatrix A);
real SparseMatrix_pseudo_diameter_weighted(SparseMatrix A0, int root, int aggressive, int *end1, int *end2, int *connectedQ); /* assume real distances, unsymmetric matrix ill be symmetrized */
real SparseMatrix_pseudo_diameter_unweighted(SparseMatrix A0, int root, int aggressive, int *end1, int *end2, int *connectedQ); /* assume unit edge length, unsymmetric matrix ill be symmetrized */
void SparseMatrix_level_sets(SparseMatrix A, int root, int *nlevel, int **levelset_ptr, int **levelset, int **mask, int reintialize_mask);