|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Adjacency matrix mapped to an adjacency list graph. More...
#include <tpl_matgraph.H>
Classes | |
| struct | Mat_Entry |
Public Types | |
| using | Graph_Type = GT |
| The associated graph type. | |
| using | Node_Type = typename GT::Node_Type |
| Node attribute type from the graph. | |
| using | Arc_Type = typename GT::Arc_Type |
| Arc attribute type from the graph. | |
| using | Node = typename GT::Node |
| Node type from the graph. | |
| using | Arc = typename GT::Arc |
| Arc type from the graph. | |
Public Member Functions | |
| void | copy_list_graph (GT &g) |
| Copy graph structure to matrix. | |
| Map_Matrix_Graph (GT &g, SA &&__sa=SA()) | |
| Construct from adjacency list graph. | |
| Map_Matrix_Graph (GT &g, SA &__sa) | |
| Construct from adjacency list graph. | |
| Map_Matrix_Graph (Map_Matrix_Graph &other) | |
| Copy constructor. | |
| Map_Matrix_Graph & | operator= (Map_Matrix_Graph &other) |
| Copy assignment. | |
| Map_Matrix_Graph & | operator= (GT &g) |
| Assign from graph. | |
| Node * | operator() (long i) |
| Get node pointer by index. | |
| long | operator() (Node *node) const |
| Get index of node. | |
| Arc * | operator() (Node *src_node, Node *tgt_node) const |
| Get arc by node pointers. | |
| Arc * | operator() (long i, long j) const |
| Get arc by indices. | |
| GT & | get_list_graph () noexcept |
| Get reference to underlying graph. | |
| const GT & | get_list_graph () const noexcept |
| Get reference to underlying graph (const) | |
| size_t | get_num_nodes () const noexcept |
| Get number of nodes (matrix dimension) | |
Private Attributes | |
| DynArray< Node * > | nodes |
| GT * | lgraph = nullptr |
| size_t | num_nodes = 0 |
| SA | sa |
| DynArray< Mat_Entry > | mat |
Adjacency matrix mapped to an adjacency list graph.
Map_Matrix_Graph provides an adjacency matrix view of a graph that is represented using adjacency lists. Matrix entries are pointers to arcs in the underlying graph. A nullptr entry indicates no arc exists.
| GT | Graph type (derived from List_Graph or similar) |
| SA | Arc filter (default: show all arcs) |
Definition at line 248 of file tpl_matgraph.H.
Arc type from the graph.
Definition at line 264 of file tpl_matgraph.H.
| using Aleph::Map_Matrix_Graph< GT, SA >::Arc_Type = typename GT::Arc_Type |
Arc attribute type from the graph.
Definition at line 258 of file tpl_matgraph.H.
| using Aleph::Map_Matrix_Graph< GT, SA >::Graph_Type = GT |
The associated graph type.
Definition at line 252 of file tpl_matgraph.H.
Node type from the graph.
Definition at line 261 of file tpl_matgraph.H.
| using Aleph::Map_Matrix_Graph< GT, SA >::Node_Type = typename GT::Node_Type |
Node attribute type from the graph.
Definition at line 255 of file tpl_matgraph.H.
|
inline |
Construct from adjacency list graph.
| g | Source graph |
| __sa | Arc filter (rvalue reference) |
| std::bad_alloc | if memory allocation fails |
Definition at line 296 of file tpl_matgraph.H.
References Aleph::Map_Matrix_Graph< GT, SA >::copy_list_graph().
|
inline |
Construct from adjacency list graph.
| g | Source graph |
| __sa | Arc filter (lvalue reference) |
| std::bad_alloc | if memory allocation fails |
Definition at line 308 of file tpl_matgraph.H.
References Aleph::Map_Matrix_Graph< GT, SA >::copy_list_graph().
|
inline |
Copy constructor.
Definition at line 315 of file tpl_matgraph.H.
References Aleph::Map_Matrix_Graph< GT, SA >::copy_list_graph(), and Aleph::maps().
Copy graph structure to matrix.
Rebuilds the matrix from the given graph. Previous contents are cleared.
| g | Graph to copy from |
Definition at line 411 of file tpl_matgraph.H.
References Aleph::DynArray< T >::cut(), GraphCommon< GT, Node, Arc >::get_connected_node(), GraphCommon< GT, Node, Arc >::get_num_nodes(), Aleph::maps(), nodes, num_nodes, and Aleph::quicksort().
Referenced by Aleph::Map_Matrix_Graph< GT, SA >::Map_Matrix_Graph(), Aleph::Map_Matrix_Graph< GT, SA >::Map_Matrix_Graph(), and Aleph::Map_Matrix_Graph< GT, SA >::Map_Matrix_Graph().
|
inlinenoexcept |
Get reference to underlying graph (const)
Definition at line 384 of file tpl_matgraph.H.
References Aleph::Map_Matrix_Graph< GT, SA >::lgraph.
|
inlinenoexcept |
Get reference to underlying graph.
Definition at line 381 of file tpl_matgraph.H.
References Aleph::Map_Matrix_Graph< GT, SA >::lgraph.
Referenced by TEST_F().
|
inlinenoexcept |
Get number of nodes (matrix dimension)
Definition at line 387 of file tpl_matgraph.H.
References Aleph::Map_Matrix_Graph< GT, SA >::num_nodes.
|
inline |
Get node pointer by index.
| i | Node index |
| std::out_of_range | if i >= num_nodes |
Definition at line 333 of file tpl_matgraph.H.
References Aleph::Map_Matrix_Graph< GT, SA >::nodes.
|
inline |
Get arc by indices.
| i | Source node index |
| j | Target node index |
| std::out_of_range | if indices out of bounds |
Definition at line 374 of file tpl_matgraph.H.
References Aleph::Map_Matrix_Graph< GT, SA >::Mat_Entry::arc, Aleph::Map_Matrix_Graph< GT, SA >::mat, and Aleph::Map_Matrix_Graph< GT, SA >::num_nodes.
|
inline |
Get index of node.
| node | Node pointer |
Definition at line 344 of file tpl_matgraph.H.
References Aleph::Map_Matrix_Graph< GT, SA >::nodes, and Aleph::Map_Matrix_Graph< GT, SA >::num_nodes.
|
inline |
Get arc by node pointers.
| src_node | Source node |
| tgt_node | Target node |
Definition at line 356 of file tpl_matgraph.H.
References Aleph::Map_Matrix_Graph< GT, SA >::Mat_Entry::arc, Aleph::Map_Matrix_Graph< GT, SA >::mat, Aleph::Map_Matrix_Graph< GT, SA >::nodes, and Aleph::Map_Matrix_Graph< GT, SA >::num_nodes.
| Map_Matrix_Graph< GT, SA > & Aleph::Map_Matrix_Graph< GT, SA >::operator= | ( | GT & | g | ) |
Assign from graph.
Definition at line 403 of file tpl_matgraph.H.
| Map_Matrix_Graph< GT, SA > & Aleph::Map_Matrix_Graph< GT, SA >::operator= | ( | Map_Matrix_Graph< GT, SA > & | other | ) |
|
private |
Definition at line 275 of file tpl_matgraph.H.
Referenced by Aleph::Map_Matrix_Graph< GT, SA >::get_list_graph(), and Aleph::Map_Matrix_Graph< GT, SA >::get_list_graph().
|
private |
Definition at line 278 of file tpl_matgraph.H.
Referenced by Aleph::Map_Matrix_Graph< GT, SA >::operator()(), and Aleph::Map_Matrix_Graph< GT, SA >::operator()().
|
private |
Definition at line 274 of file tpl_matgraph.H.
Referenced by Aleph::Map_Matrix_Graph< GT, SA >::operator()(), Aleph::Map_Matrix_Graph< GT, SA >::operator()(), and Aleph::Map_Matrix_Graph< GT, SA >::operator()().
|
mutableprivate |
Definition at line 276 of file tpl_matgraph.H.
Referenced by Aleph::Map_Matrix_Graph< GT, SA >::get_num_nodes(), Aleph::Map_Matrix_Graph< GT, SA >::operator()(), Aleph::Map_Matrix_Graph< GT, SA >::operator()(), and Aleph::Map_Matrix_Graph< GT, SA >::operator()().
Definition at line 277 of file tpl_matgraph.H.