-
Notifications
You must be signed in to change notification settings - Fork 0
/
connectivity.h
54 lines (46 loc) · 2.46 KB
/
connectivity.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* Functions to analyze whether or not a matrix is block diagonal if the rows and columns
* are just rearranged.
*
*/
#ifndef CONNECTIVITY_H
#define CONNECTIVITY_H
#include <Eigen/Dense>
#include <vector>
// Depth-first search function, which goes through the graph defined by the
// connectivities of the matrix mat.
// At each visited site, the visit_count counter is incremented by 1. The search continues
// untll all the site accessable from the initial site have been visited at least once.
//
// Input:
// const int node: the node in the graph to start the search
// Eigen::VectorXi& visit_count: the numbers of times the distinct nodes are viisted
// const Eigen::MatrixXcd& mat: the matrix defining the connectivities between nodes
// const double tresh: the minimum threshold for connection between two nodes
void DFS(const int node, Eigen::VectorXi& visit_count, const Eigen::MatrixXcd& mat, const double tresh);
// Find distinct disconnected branches in the graph defined by a matrix by using
// DFS
// Input:
// const Eigen::MatrixXcd& mat: the matrix defining the connectivities between nodes
// const double tresh: the minimum threshold for connection between two nodes
// Output:
// std::vector<std::vector<int>>: list of disconnected branches, each branch given as a list of nodes
std::vector<std::vector<int>> unconnected_branches_DFS(const Eigen::MatrixXcd& mat, const double tresh);
// Find the index of class, that is, a branch of a node
// Input:
// int node: the node in consideration
// const std::vector<std::vector<int>>& classes: list of classes, each consisting of a set of nodes
// Output: the class index
int find_class(int node, const std::vector<std::vector<int>>& classes);
// Produce a matrix <num of nodes> x 2 matrix, where rows correspond to
// nodes in the graph and the two columns correspond to class indices of
// the nodes and the index of the nodes within the class, respectively.
// Input: const std::vector<std::vector<int>>& a: list of classes in a node, each
// corresponding to the list of nodes in the class
// Output: Eigen::MatrixXi containing the desribed matrix
Eigen::MatrixXi class_division_table(const std::vector<std::vector<int>>& a);
// Get the unconnected components of two merged connectivities
// Input: two lists of unconnected branches
// Input: list of unconnected branches in the merged
std::vector<std::vector<int>> unconnected_branches_merge(const std::vector<std::vector<int>>& a, const std::vector<std::vector<int>>& b);
#endif