|
Aleph-w 7.10.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. | |
| Graph_Lattice (const Graph_Lattice &other)=default | |
| Copy another lattice: its cells and its adjacency. | |
| Graph_Lattice (Graph_Lattice &&other) noexcept | |
| Take the cells and the adjacency of another lattice, which is left with no nodes. | |
| Graph_Lattice & | operator= (const Graph_Lattice &other)=default |
| Copy another lattice into this one: its cells and its adjacency. | |
| Graph_Lattice & | operator= (Graph_Lattice &&other) noexcept |
| Exchange this lattice with another, which is left with the previous nodes of this one. | |
| 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.
| using Aleph::CA::Graph_Lattice< T >::coord_type = Coord_Vec<1> |
Definition at line 113 of file tpl_ca_graph_automaton.H.
| using Aleph::CA::Graph_Lattice< T >::extents_type = std::array<ca_size_t, 1> |
Definition at line 114 of file tpl_ca_graph_automaton.H.
| using Aleph::CA::Graph_Lattice< T >::state_type = T |
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.
|
default |
Copy another lattice: its cells and its adjacency.
| [in] | other | lattice to copy. |
|
inlinenoexcept |
Take the cells and the adjacency of another lattice, which is left with no nodes.
The implicit move took the cells and the adjacency but copied the node count: the moved-from lattice then read nodes that it no longer had.
| [in,out] | other | lattice to move from. |
Definition at line 174 of file tpl_ca_graph_automaton.H.
|
inline |
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_.
Referenced by TEST(), and Moved_From_Case< Graph_Lattice< int > >::use().
|
inline |
Direct read at node id n.
Definition at line 246 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_.
Referenced by Moved_From_Case< Graph_Lattice< int > >::fingerprint(), TEST(), TEST(), and Moved_From_Case< Graph_Lattice< int > >::use().
|
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 234 of file tpl_ca_graph_automaton.H.
References Aleph::CA::Graph_Lattice< T >::cells_, and Aleph::CA::Graph_Lattice< T >::num_nodes_.
Referenced by TEST().
|
inline |
Degree of node n.
Definition at line 262 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_.
Referenced by Moved_From_Case< Graph_Lattice< int > >::fingerprint(), TEST(), and Moved_From_Case< Graph_Lattice< int > >::use().
|
inlinestaticconstexprnoexcept |
Definition at line 201 of file tpl_ca_graph_automaton.H.
References Aleph::CA::Graph_Lattice< T >::rank.
|
inlinenoexcept |
Definition at line 212 of file tpl_ca_graph_automaton.H.
References Aleph::CA::Graph_Lattice< T >::num_nodes_.
|
inline |
Set every cell to value.
Definition at line 288 of file tpl_ca_graph_automaton.H.
References Aleph::CA::Graph_Lattice< T >::cells_, Aleph::CA::Graph_Lattice< T >::num_nodes_, and value.
Referenced by TEST(), and Moved_From_Case< Graph_Lattice< int > >::use().
|
inlinenoexcept |
Maximum degree across the graph (computed in O(N)).
Definition at line 278 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().
Referenced by Moved_From_Case< Graph_Lattice< int > >::is_empty(), TEST(), and Moved_From_Case< Graph_Lattice< int > >::use().
|
inline |
Neighbour ids of node n in the order supplied at construction.
Definition at line 270 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_.
Referenced by Moved_From_Case< Graph_Lattice< int > >::use().
|
default |
Copy another lattice into this one: its cells and its adjacency.
| [in] | other | lattice to copy. |
|
inlinenoexcept |
Exchange this lattice with another, which is left with the previous nodes of this one.
| [in,out] | other | lattice to move from. |
Definition at line 191 of file tpl_ca_graph_automaton.H.
References Aleph::CA::Graph_Lattice< T >::swap().
|
inline |
Definition at line 224 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_.
Referenced by Moved_From_Case< Graph_Lattice< int > >::use().
|
inline |
Direct write at node id n.
Definition at line 254 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_.
Referenced by Moved_From_Case< Graph_Life >::make(), TEST(), TEST(), TEST(), TEST(), and Moved_From_Case< Graph_Lattice< int > >::use().
|
inlinenoexcept |
Definition at line 203 of file tpl_ca_graph_automaton.H.
References Aleph::CA::Graph_Lattice< T >::num_nodes_.
Referenced by Moved_From_Case< Graph_Lattice< int > >::fingerprint(), Moved_From_Case< Graph_Lattice< int > >::is_empty(), Aleph::CA::Graph_Lattice< T >::max_degree(), TEST(), TEST(), TEST(), and Moved_From_Case< Graph_Lattice< int > >::use().
|
inline |
Definition at line 205 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 295 of file tpl_ca_graph_automaton.H.
References Aleph::CA::Graph_Lattice< T >::adjacency_, 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 >::operator=(), and 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().
|
private |
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().