|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Graph lattice: one cell per node + precomputed adjacency. More...
#include <tpl_ca_graph_automaton.H>
Public Types | |
| using | state_type = T |
| using | coord_type = Coord_Vec< 1 > |
| using | extents_type = std::array< ca_size_t, 1 > |
Public Member Functions | |
| Graph_Lattice ()=default | |
| Construct an empty graph lattice (0 nodes). | |
| Graph_Lattice (const Array< Array< std::size_t > > &adjacency, const T &init=T{}) | |
| Build a graph lattice from an adjacency list. | |
| ca_size_t | size () const noexcept |
| ca_size_t | size (std::size_t d) const |
| extents_type | extents () const noexcept |
| T | at (const coord_type &c) const |
| void | set (const coord_type &c, const T &v) |
| T | at_safe (const coord_type &c) const |
| Boundary-aware read. | |
| T | at_node (std::size_t n) const |
Direct read at node id n. | |
| void | set_node (std::size_t n, const T &v) |
Direct write at node id n. | |
| std::size_t | degree (std::size_t n) const |
Degree of node n. | |
| const Array< std::size_t > & | neighbours (std::size_t n) const |
Neighbour ids of node n in the order supplied at construction. | |
| std::size_t | max_degree () const noexcept |
| Maximum degree across the graph (computed in O(N)). | |
| void | fill (const T &value) |
Set every cell to value. | |
| void | swap (Graph_Lattice &other) noexcept |
| O(1) swap with another graph lattice of the same type. | |
Static Public Member Functions | |
| static constexpr std::size_t | dimension () noexcept |
Static Public Attributes | |
| static constexpr std::size_t | rank = 1 |
| Rank-1 lattice: node id is the only axis. | |
Private Attributes | |
| ca_size_t | num_nodes_ = 0 |
| Array< T > | cells_ {} |
| Array< Array< std::size_t > > | adjacency_ {} |
Graph lattice: one cell per node + precomputed adjacency.
Satisfies LatticeLike as a rank-1 lattice whose coord_type is Coord_Vec<1> and whose extents_type is std::array<ca_size_t, 1>. Component 0 is interpreted as the node id.
Adjacency is stored as Array<Array<size_t>>: row n lists the ids of the neighbours of node n. The list is what the engine hands to the rule, in the order supplied by the constructor. Self-loops are accepted but have no special semantics: they show up as the node's own id in its own adjacency list.
| T | cell state type, must satisfy CellState. |
Definition at line 107 of file tpl_ca_graph_automaton.H.
Definition at line 113 of file tpl_ca_graph_automaton.H.
Definition at line 114 of file tpl_ca_graph_automaton.H.
Definition at line 112 of file tpl_ca_graph_automaton.H.
|
default |
Construct an empty graph lattice (0 nodes).
|
inlineexplicit |
Build a graph lattice from an adjacency list.
| [in] | adjacency | one row per node listing neighbour ids. |
| [in] | init | initial value for every cell (default T{}). |
| std::out_of_range | if a neighbour id is >= adjacency.size(). |
| std::bad_alloc | on allocation failure. |
Definition at line 139 of file tpl_ca_graph_automaton.H.
|
inline |
Definition at line 180 of file tpl_ca_graph_automaton.H.
References ah_out_of_range_error_if, Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Graph_Lattice< T >::cells_, and Aleph::CA::Graph_Lattice< T >::num_nodes_.
|
inline |
Direct read at node id n.
Definition at line 209 of file tpl_ca_graph_automaton.H.
References ah_out_of_range_error_if, Aleph::CA::Graph_Lattice< T >::cells_, and Aleph::CA::Graph_Lattice< T >::num_nodes_.
|
inline |
Boundary-aware read.
For graphs the only meaningful interpretation is "out-of-range cells return the default value", which mirrors OpenBoundary on a rectangular lattice.
Definition at line 197 of file tpl_ca_graph_automaton.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Graph_Lattice< T >::cells_, and Aleph::CA::Graph_Lattice< T >::num_nodes_.
|
inline |
Degree of node n.
Definition at line 225 of file tpl_ca_graph_automaton.H.
References Aleph::CA::Graph_Lattice< T >::adjacency_, ah_out_of_range_error_if, and Aleph::CA::Graph_Lattice< T >::num_nodes_.
|
inlinestaticconstexprnoexcept |
Definition at line 164 of file tpl_ca_graph_automaton.H.
References Aleph::CA::Graph_Lattice< T >::rank.
|
inlinenoexcept |
Definition at line 175 of file tpl_ca_graph_automaton.H.
References Aleph::CA::Graph_Lattice< T >::num_nodes_.
Set every cell to value.
Definition at line 251 of file tpl_ca_graph_automaton.H.
References Aleph::CA::Graph_Lattice< T >::cells_, Aleph::CA::Graph_Lattice< T >::num_nodes_, and value.
|
inlinenoexcept |
Maximum degree across the graph (computed in O(N)).
Definition at line 241 of file tpl_ca_graph_automaton.H.
References Aleph::CA::Graph_Lattice< T >::adjacency_, m, Aleph::CA::Graph_Lattice< T >::num_nodes_, OhashCommon< HashTbl, Key >::size(), and Aleph::CA::Graph_Lattice< T >::size().
|
inline |
Neighbour ids of node n in the order supplied at construction.
Definition at line 233 of file tpl_ca_graph_automaton.H.
References Aleph::CA::Graph_Lattice< T >::adjacency_, ah_out_of_range_error_if, and Aleph::CA::Graph_Lattice< T >::num_nodes_.
|
inline |
Definition at line 187 of file tpl_ca_graph_automaton.H.
References ah_out_of_range_error_if, Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Graph_Lattice< T >::cells_, and Aleph::CA::Graph_Lattice< T >::num_nodes_.
|
inline |
Direct write at node id n.
Definition at line 217 of file tpl_ca_graph_automaton.H.
References ah_out_of_range_error_if, Aleph::CA::Graph_Lattice< T >::cells_, and Aleph::CA::Graph_Lattice< T >::num_nodes_.
|
inlinenoexcept |
Definition at line 166 of file tpl_ca_graph_automaton.H.
References Aleph::CA::Graph_Lattice< T >::num_nodes_.
Referenced by Aleph::CA::Graph_Lattice< T >::max_degree(), and TEST().
|
inline |
Definition at line 168 of file tpl_ca_graph_automaton.H.
References ah_out_of_range_error_if, Aleph::CA::Graph_Lattice< T >::num_nodes_, and Aleph::CA::Graph_Lattice< T >::rank.
|
inlinenoexcept |
O(1) swap with another graph lattice of the same type.
Definition at line 258 of file tpl_ca_graph_automaton.H.
References Aleph::CA::Graph_Lattice< T >::adjacency_, Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Graph_Lattice< T >::cells_, Aleph::CA::Graph_Lattice< T >::num_nodes_, and Aleph::CA::Graph_Lattice< T >::swap().
Referenced by Aleph::CA::Graph_Lattice< T >::swap().
|
private |
Definition at line 122 of file tpl_ca_graph_automaton.H.
Referenced by Aleph::CA::Graph_Lattice< T >::degree(), Aleph::CA::Graph_Lattice< T >::max_degree(), Aleph::CA::Graph_Lattice< T >::neighbours(), and Aleph::CA::Graph_Lattice< T >::swap().
Definition at line 121 of file tpl_ca_graph_automaton.H.
Referenced by Aleph::CA::Graph_Lattice< T >::at(), Aleph::CA::Graph_Lattice< T >::at_node(), Aleph::CA::Graph_Lattice< T >::at_safe(), Aleph::CA::Graph_Lattice< T >::fill(), Aleph::CA::Graph_Lattice< T >::set(), Aleph::CA::Graph_Lattice< T >::set_node(), and Aleph::CA::Graph_Lattice< T >::swap().
|
private |
Definition at line 120 of file tpl_ca_graph_automaton.H.
Referenced by Aleph::CA::Graph_Lattice< T >::at(), Aleph::CA::Graph_Lattice< T >::at_node(), Aleph::CA::Graph_Lattice< T >::at_safe(), Aleph::CA::Graph_Lattice< T >::degree(), Aleph::CA::Graph_Lattice< T >::extents(), Aleph::CA::Graph_Lattice< T >::fill(), Aleph::CA::Graph_Lattice< T >::max_degree(), Aleph::CA::Graph_Lattice< T >::neighbours(), Aleph::CA::Graph_Lattice< T >::set(), Aleph::CA::Graph_Lattice< T >::set_node(), Aleph::CA::Graph_Lattice< T >::size(), Aleph::CA::Graph_Lattice< T >::size(), and Aleph::CA::Graph_Lattice< T >::swap().
|
staticconstexpr |
Rank-1 lattice: node id is the only axis.
Definition at line 117 of file tpl_ca_graph_automaton.H.
Referenced by Aleph::CA::Graph_Lattice< T >::dimension(), and Aleph::CA::Graph_Lattice< T >::size().