TestProject
0.0.1
|
Public Member Functions | |
MySparseMatrix (int V, std::vector< int > reserve) | |
void | print_heap () |
void | print_heap (int row) |
bool | heap_empty () |
max_heap_type | heap_top () |
void | update (int row, int col, float val) |
void | insert (int row, int col, float val) |
void | erase (int row, int col) |
std::map< int, float > & | row (int r) |
int | innerNonZero (int row) |
void | setZero (int row) |
void | print (std::ostream &stream) |
Private Member Functions | |
void | print_heap (std::vector< max_heap_type > &H, std::vector< int > &H_ind, std::vector< int > &H_pos) |
bool | heap_empty (std::vector< int > &H_ind) |
int | heap_size (std::vector< int > &H_ind) |
void | upheap (std::vector< max_heap_type > &H, std::vector< int > &H_ind, std::vector< int > &H_pos, int pos_heap) |
void | downheap (std::vector< max_heap_type > &H, std::vector< int > &H_ind, std::vector< int > &H_pos, int pos_heap) |
void | heap_update (std::vector< max_heap_type > &H, std::vector< int > &H_ind, std::vector< int > &H_pos, int pos_heap, max_heap_type h_new) |
void | heap_insert (std::vector< max_heap_type > &H, std::vector< int > &H_ind, std::vector< int > &H_pos, max_heap_type h) |
void | heap_erase (std::vector< max_heap_type > &H, std::vector< int > &H_ind, std::vector< int > &H_pos, int pos_heap) |
Private Attributes | |
std::vector< std::map< int, float > > | _row |
std::vector< max_heap_type > | _H |
std::vector< int > | _H_ind |
std::vector< int > | _H_pos |
std::vector< std::vector< max_heap_type > > | _H_k |
std::vector< std::vector< int > > | _H_k_ind |
std::vector< std::vector< int > > | _H_k_pos |
std::vector< std::map< int, int > > | _H_k_map |
sparse matrix implementation for fast modularity clustering algorithm, as described in:
The matrix can store explicit zeros, and access to elements is only allowed if they have been set before.
The data structure allows insert, removal and updates of arbitrary elements and keeps track of the maximum element of each row and the whole matrix in an efficient manner.
Insert, removal and update of elements, including book-keeping required to keep track of maximum elements, can be performed in O(n log n).
Definition at line 111 of file SFCLayoutAlgorithm.cpp.
|
inline |
Construct sparse matrix with predefined size and number of elements in each row.
V | number of nodes |
reserve | vector containing size of each row |
Definition at line 341 of file SFCLayoutAlgorithm.cpp.
|
inlineprivate |
Perform a downheap operation after the heap has been changed.
H | the elements of the heap |
H_ind | the indirect array of the heap |
H_pos | the position vector of the heap |
pos_heap | the heap position that has changed |
Definition at line 218 of file SFCLayoutAlgorithm.cpp.
|
inline |
Erase an element from the matrix. The element to be removed must exist.
row | the row index of the element |
col | the column index of the element |
Definition at line 467 of file SFCLayoutAlgorithm.cpp.
|
inlineprivate |
Check if a given heap is empty.
H_ind | the indirect array of the heap |
Definition at line 172 of file SFCLayoutAlgorithm.cpp.
|
inline |
Check if max-heap of all rows is empty.
Definition at line 383 of file SFCLayoutAlgorithm.cpp.
|
inlineprivate |
Perform a heap erase operation which removes an existing element from the heap.
H | the elements of the heap |
H_ind | the indirect array of the heap |
H_pos | the position vector of the heap |
pos_heap | the heap position of the element to remove |
Definition at line 305 of file SFCLayoutAlgorithm.cpp.
|
inlineprivate |
Insert a new element into a heap.
H | the elements of the heap |
H_ind | the indirect array of the heap |
H_pos | the position vector of the heap |
h | the value of the new heap element |
Definition at line 285 of file SFCLayoutAlgorithm.cpp.
|
inlineprivate |
Return size of heap.
H_ind | the indirect array of the heap |
Definition at line 181 of file SFCLayoutAlgorithm.cpp.
|
inline |
Get the top element of all heaps. The heap must not be empty.
Definition at line 391 of file SFCLayoutAlgorithm.cpp.
|
inlineprivate |
Perform a heap update operation by changing the value of an existing heap element.
H | the elements of the heap |
H_ind | the indirect array of the heap |
H_pos | the position vector of the heap |
pos_heap | the heap position that is updated |
h_new | the new value of the heap element |
Definition at line 258 of file SFCLayoutAlgorithm.cpp.
|
inline |
Get the number of elements of a row.
row | the selected row |
Definition at line 513 of file SFCLayoutAlgorithm.cpp.
|
inline |
Perform a matrix insert operation. The element to be inserted must not exist.
row | the row index of the element |
col | the column index of the element |
val | the new value for the element |
Definition at line 430 of file SFCLayoutAlgorithm.cpp.
|
inline |
Print the whole matrix (for debugging).
stream | print the matrix to this stream |
Definition at line 544 of file SFCLayoutAlgorithm.cpp.
|
inlineprivate |
Print heap (for debugging).
H | the elements of the heap |
H_ind | the indirect array of the heap |
H_pos | the position vector of the heap |
Definition at line 145 of file SFCLayoutAlgorithm.cpp.
|
inline |
Print heap of maximum elements of each row.
Definition at line 367 of file SFCLayoutAlgorithm.cpp.
|
inline |
Print heap of a given row.
row | the heap to print |
Definition at line 375 of file SFCLayoutAlgorithm.cpp.
|
inline |
Retrieve the container for elements of row The container and its elements must not be modified this way.
r | the row to retrieve |
Definition at line 504 of file SFCLayoutAlgorithm.cpp.
|
inline |
Remove all elements from a row and update heaps The row to be removed may already be empty.
row | the row to remove |
Definition at line 521 of file SFCLayoutAlgorithm.cpp.
|
inlineprivate |
Perform an upheap operation after the heap has been changed.
H | the elements of the heap |
H_ind | the indirect array of the heap |
H_pos | the position vector of the heap |
pos_heap | the heap position that has changed |
Definition at line 192 of file SFCLayoutAlgorithm.cpp.
|
private |
main heap for largest elements of each row with non-zero elements
Definition at line 119 of file SFCLayoutAlgorithm.cpp.
|
private |
indirect array of elements in main heap
Definition at line 122 of file SFCLayoutAlgorithm.cpp.
|
private |
max_heaps for rows with non-zero elements
Definition at line 129 of file SFCLayoutAlgorithm.cpp.
|
private |
indirect arrays of elements in heap of each row
Definition at line 132 of file SFCLayoutAlgorithm.cpp.
|
private |
vector of maps between key value (column) and position in element array
Definition at line 138 of file SFCLayoutAlgorithm.cpp.
|
private |
vector of positions of elements in heap of each row
Definition at line 135 of file SFCLayoutAlgorithm.cpp.
|
private |
vector of positions of heap elements in main heap
Definition at line 125 of file SFCLayoutAlgorithm.cpp.
|
private |
main index, organized in row major fashion
Definition at line 115 of file SFCLayoutAlgorithm.cpp.