|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Auxiliary adjacency matrix with custom entry type. More...
#include <tpl_matgraph.H>
Public Types | |
| using | Graph_Type = GT |
| Graph type. | |
| using | Entry_Type = __Entry_Type |
| Entry type stored in matrix. | |
| using | Node_Type = typename GT::Node_Type |
| Node attribute type from graph. | |
| using | Arc_Type = typename GT::Arc_Type |
| Arc attribute type from graph. | |
| using | Node = typename GT::Node |
| Node type from graph. | |
| using | Arc = typename GT::Arc |
| Arc type from graph. | |
Public Member Functions | |
| Node * | operator() (long i) |
| Get node pointer by index. | |
| Node * | operator() (long i) const |
| Get node pointer by index (const). | |
| long | operator() (Node *node) const |
| Get index of node. | |
| Entry_Type & | operator() (long i, long j) |
| Access entry by indices (modifiable). | |
| const Entry_Type & | operator() (long i, long j) const |
| Access entry by indices (const). | |
| Entry_Type & | operator() (Node *src, Node *tgt) |
| Access entry by node pointers (modifiable). | |
| const Entry_Type & | operator() (Node *src, Node *tgt) const |
| Access entry by node pointers (const). | |
| GT & | get_list_graph () noexcept |
| Get reference to underlying graph. | |
| const GT & | get_list_graph () const noexcept |
| Get const reference to underlying graph. | |
| const Entry_Type & | null_value () const noexcept |
| Get the null value. | |
| size_t | get_num_nodes () const noexcept |
| Get number of nodes (matrix dimension) | |
| Ady_Mat (GT &g, SA arc_filter=SA()) | |
| Construct from graph without null value. | |
| Ady_Mat (GT &g, const Entry_Type &null, SA arc_filter=SA()) | |
| Construct from graph with null value. | |
| void | set_null_value (const Entry_Type &null) noexcept |
| Set the null value. | |
| Ady_Mat (const Ady_Mat &other) | |
| Copy constructor: the graph, the entries, the null value and the filter of other. | |
| Ady_Mat & | operator= (const Ady_Mat &other) |
| Copy assignment from a matrix of the same graph: its entries, its null value and its filter. | |
| template<class Operation > | |
| void | operate_all_arcs_list_graph () |
| Apply operation to all arcs from the graph. | |
| template<class Operation > | |
| void | operate_all_arcs_list_graph (void *ptr) |
| Apply operation to all arcs with user data. | |
| template<class Operation > | |
| void | operate_all_arcs_matrix () |
| Apply operation to all matrix entries. | |
| template<class Operation > | |
| void | operate_all_arcs_matrix (void *ptr) |
| Apply operation to all matrix entries with user data. | |
Private Member Functions | |
| void | test_same_graph (const Ady_Mat &other) const |
| void | copy_nodes (GT &g) |
| Ady_Mat & | copy (const Ady_Mat &other) |
Private Attributes | |
| GT * | lgraph = nullptr |
| SA | sa |
| the filter of the arcs that the operations visit | |
| DynArray< Node * > | nodes |
| DynArray< Entry_Type > | mat |
| size_t | num_nodes = 0 |
| Entry_Type | Null_Value {} |
Auxiliary adjacency matrix with custom entry type.
Ady_Mat provides an adjacency matrix with a user-defined entry type, useful for algorithms that need temporary storage or computations different from the graph's native attributes.
| GT | Graph type |
| __Entry_Type | Type of matrix entries |
| SA | Arc filter (default: show all arcs); the constructors take the object, which operate_all_arcs_list_graph() calls |
Definition at line 694 of file tpl_matgraph.H.
| using Aleph::Ady_Mat< GT, __Entry_Type, SA >::Arc = typename GT::Arc |
Arc type from graph.
Definition at line 713 of file tpl_matgraph.H.
| using Aleph::Ady_Mat< GT, __Entry_Type, SA >::Arc_Type = typename GT::Arc_Type |
Arc attribute type from graph.
Definition at line 707 of file tpl_matgraph.H.
| using Aleph::Ady_Mat< GT, __Entry_Type, SA >::Entry_Type = __Entry_Type |
Entry type stored in matrix.
Definition at line 701 of file tpl_matgraph.H.
| using Aleph::Ady_Mat< GT, __Entry_Type, SA >::Graph_Type = GT |
Graph type.
Definition at line 698 of file tpl_matgraph.H.
| using Aleph::Ady_Mat< GT, __Entry_Type, SA >::Node = typename GT::Node |
Node type from graph.
Definition at line 710 of file tpl_matgraph.H.
| using Aleph::Ady_Mat< GT, __Entry_Type, SA >::Node_Type = typename GT::Node_Type |
Node attribute type from graph.
Definition at line 704 of file tpl_matgraph.H.
|
inlineexplicit |
Construct from graph without null value.
Creates matrix with uninitialized entries. Use set_null_value() to define the null value.
| g | Source graph |
| arc_filter | the filter of the arcs that operate_all_arcs_list_graph() visits |
| std::bad_alloc | if memory allocation fails |
Definition at line 864 of file tpl_matgraph.H.
References Aleph::Ady_Mat< GT, __Entry_Type, SA >::copy_nodes().
|
inline |
Construct from graph with null value.
| g | Source graph |
| null | Value indicating no entry |
| arc_filter | the filter of the arcs that operate_all_arcs_list_graph() visits |
| std::bad_alloc | if memory allocation fails |
Definition at line 878 of file tpl_matgraph.H.
References Aleph::Ady_Mat< GT, __Entry_Type, SA >::copy_nodes().
|
inline |
Copy constructor: the graph, the entries, the null value and the filter of other.
Definition at line 890 of file tpl_matgraph.H.
|
inlineprivate |
Definition at line 742 of file tpl_matgraph.H.
References Aleph::Ady_Mat< GT, __Entry_Type, SA >::mat, Aleph::Ady_Mat< GT, __Entry_Type, SA >::nodes, Aleph::Ady_Mat< GT, __Entry_Type, SA >::Null_Value, Aleph::Ady_Mat< GT, __Entry_Type, SA >::num_nodes, Aleph::Ady_Mat< GT, __Entry_Type, SA >::sa, and Aleph::Ady_Mat< GT, __Entry_Type, SA >::test_same_graph().
Referenced by Aleph::Ady_Mat< GT, __Entry_Type, SA >::operator=().
|
inlineprivate |
Definition at line 729 of file tpl_matgraph.H.
References Aleph::DynArray< T >::cut(), GraphCommon< GT, Node, Arc >::get_num_nodes(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::lgraph, Aleph::Ady_Mat< GT, __Entry_Type, SA >::nodes, Aleph::Ady_Mat< GT, __Entry_Type, SA >::num_nodes, and Aleph::quicksort().
Referenced by Aleph::Ady_Mat< GT, __Entry_Type, SA >::Ady_Mat(), and Aleph::Ady_Mat< GT, __Entry_Type, SA >::Ady_Mat().
|
inlinenoexcept |
Get const reference to underlying graph.
Definition at line 845 of file tpl_matgraph.H.
References Aleph::Ady_Mat< GT, __Entry_Type, SA >::lgraph.
|
inlinenoexcept |
Get reference to underlying graph.
Definition at line 842 of file tpl_matgraph.H.
References Aleph::Ady_Mat< GT, __Entry_Type, SA >::lgraph.
Referenced by Aleph::Initialize_Dist< AM, Compare >::operator()(), and TEST_F().
|
inlinenoexcept |
Get number of nodes (matrix dimension)
Definition at line 851 of file tpl_matgraph.H.
References Aleph::Ady_Mat< GT, __Entry_Type, SA >::num_nodes.
Referenced by FloydSimpleGraphTest::get_index(), Aleph::latex_floyd_detail::initialize_matrices(), TEST(), TEST_F(), and TEST_F().
|
inlinenoexcept |
Get the null value.
Definition at line 848 of file tpl_matgraph.H.
References Aleph::Ady_Mat< GT, __Entry_Type, SA >::Null_Value.
| void Aleph::Ady_Mat< GT, __Entry_Type, SA >::operate_all_arcs_list_graph | ( | ) |
Apply operation to all arcs from the graph.
Iterates over the arcs of the underlying graph that the filter shows, from each end of an arc of a graph that is not directed, and invokes:
Where:
| Operation | Functor type with above signature |
Definition at line 966 of file tpl_matgraph.H.
References Aleph::matgraph_detail::index_array(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), nodes, num_nodes, and Aleph::DynArray< T >::touch().
| void Aleph::Ady_Mat< GT, __Entry_Type, SA >::operate_all_arcs_list_graph | ( | void * | ptr | ) |
Apply operation to all arcs with user data.
Same as operate_all_arcs_list_graph() but passes additional pointer:
| Operation | Functor type |
| ptr | User data pointer |
Definition at line 989 of file tpl_matgraph.H.
References Aleph::matgraph_detail::index_array(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), nodes, num_nodes, and Aleph::DynArray< T >::touch().
| void Aleph::Ady_Mat< GT, __Entry_Type, SA >::operate_all_arcs_matrix | ( | ) |
Apply operation to all matrix entries.
Iterates over all n×n entries and invokes:
| Operation | Functor type |
Definition at line 1011 of file tpl_matgraph.H.
References Aleph::matgraph_detail::index_array(), nodes, num_nodes, and Aleph::DynArray< T >::touch().
Referenced by TEST_F().
| void Aleph::Ady_Mat< GT, __Entry_Type, SA >::operate_all_arcs_matrix | ( | void * | ptr | ) |
Apply operation to all matrix entries with user data.
| Operation | Functor type |
| ptr | User data pointer |
Definition at line 1029 of file tpl_matgraph.H.
References Aleph::matgraph_detail::index_array(), nodes, num_nodes, and Aleph::DynArray< T >::touch().
|
inline |
Get node pointer by index.
| i | Node index |
| std::out_of_range | if index out of bounds |
Definition at line 763 of file tpl_matgraph.H.
References Aleph::Ady_Mat< GT, __Entry_Type, SA >::nodes.
|
inline |
Get node pointer by index (const).
| i | Node index |
| std::out_of_range | if index out of bounds |
Definition at line 774 of file tpl_matgraph.H.
References Aleph::Ady_Mat< GT, __Entry_Type, SA >::nodes.
|
inline |
Access entry by indices (modifiable).
| i | Row index |
| j | Column index |
| std::out_of_range | if indices out of bounds |
Definition at line 797 of file tpl_matgraph.H.
References Aleph::matgraph_detail::checked_index_array(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::mat, Aleph::Ady_Mat< GT, __Entry_Type, SA >::num_nodes, and Aleph::DynArray< T >::touch().
|
inline |
Access entry by indices (const).
| i | Row index |
| j | Column index |
| std::out_of_range | if indices out of bounds |
Definition at line 809 of file tpl_matgraph.H.
References Aleph::DynArray< T >::access(), Aleph::matgraph_detail::checked_index_array(), Aleph::DynArray< T >::exist(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::mat, Aleph::Ady_Mat< GT, __Entry_Type, SA >::Null_Value, and Aleph::Ady_Mat< GT, __Entry_Type, SA >::num_nodes.
|
inline |
Get index of node.
| node | Node pointer |
Definition at line 785 of file tpl_matgraph.H.
References Aleph::Ady_Mat< GT, __Entry_Type, SA >::nodes, and Aleph::Ady_Mat< GT, __Entry_Type, SA >::num_nodes.
|
inline |
Access entry by node pointers (modifiable).
| src | Source node |
| tgt | Target node |
Definition at line 822 of file tpl_matgraph.H.
References Aleph::Ady_Mat< GT, __Entry_Type, SA >::nodes, and Aleph::Ady_Mat< GT, __Entry_Type, SA >::num_nodes.
|
inline |
Access entry by node pointers (const).
| src | Source node |
| tgt | Target node |
Definition at line 835 of file tpl_matgraph.H.
References Aleph::Ady_Mat< GT, __Entry_Type, SA >::nodes, and Aleph::Ady_Mat< GT, __Entry_Type, SA >::num_nodes.
|
inline |
Copy assignment from a matrix of the same graph: its entries, its null value and its filter.
| std::domain_error | if other is of another graph |
Definition at line 901 of file tpl_matgraph.H.
References Aleph::Ady_Mat< GT, __Entry_Type, SA >::copy().
|
inlinenoexcept |
Set the null value.
Definition at line 886 of file tpl_matgraph.H.
References Aleph::Ady_Mat< GT, __Entry_Type, SA >::Null_Value.
Referenced by TEST_F().
|
inlineprivate |
Definition at line 723 of file tpl_matgraph.H.
References ah_domain_error_if, and Aleph::Ady_Mat< GT, __Entry_Type, SA >::lgraph.
Referenced by Aleph::Ady_Mat< GT, __Entry_Type, SA >::copy().
|
private |
|
private |
Definition at line 719 of file tpl_matgraph.H.
Referenced by Aleph::Ady_Mat< GT, __Entry_Type, SA >::copy(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::operator()(), and Aleph::Ady_Mat< GT, __Entry_Type, SA >::operator()().
|
private |
Definition at line 718 of file tpl_matgraph.H.
Referenced by Aleph::Ady_Mat< GT, __Entry_Type, SA >::copy(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::copy_nodes(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::operator()(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::operator()(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::operator()(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::operator()(), and Aleph::Ady_Mat< GT, __Entry_Type, SA >::operator()().
|
mutableprivate |
|
mutableprivate |
Definition at line 720 of file tpl_matgraph.H.
Referenced by Aleph::Ady_Mat< GT, __Entry_Type, SA >::copy(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::copy_nodes(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::get_num_nodes(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::operator()(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::operator()(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::operator()(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::operator()(), and Aleph::Ady_Mat< GT, __Entry_Type, SA >::operator()().
|
private |
the filter of the arcs that the operations visit
Definition at line 717 of file tpl_matgraph.H.
Referenced by Aleph::Ady_Mat< GT, __Entry_Type, SA >::copy().