|
Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
|
Compressed Sparse Row (CSR) based graph representing atomic connectivity. More...
#include <NeighborGraph.hpp>
Public Member Functions | |
| NeighborGraph ()=default | |
| Default constructor. | |
| NeighborGraph (size_t node_count) | |
| Constructs a graph with a fixed number of nodes. | |
| NeighborGraph (const NeighborGraph &other) | |
| Copy constructor. | |
| NeighborGraph (NeighborGraph &&other) noexcept | |
| Move constructor. | |
| NeighborGraph & | operator= (const NeighborGraph &other) |
| Copy assignment operator. | |
| NeighborGraph & | operator= (NeighborGraph &&other) noexcept |
| Move assignment operator. | |
| ~NeighborGraph ()=default | |
| Destructor. | |
| void | addDirectedEdge (const Edge &edge) |
| Adds a directed edge between two atoms. | |
| void | addDirectedEdge (AtomID source, AtomID target, real_t distance, const math::Vector3< real_t > &r_ij) |
| Adds a directed edge between two atoms using individual parameters. | |
| void | finalize () const |
| Finalizes the graph into Compressed Sparse Row (CSR) storage. | |
| void | assignCSR (size_t node_count, std::vector< size_t > offsets, std::vector< Neighbor > neighbors, std::vector< AtomID > targets) |
| Directly assigns Compressed Sparse Row (CSR) storage. | |
| std::span< const Neighbor > | getNeighbors (size_t atom_index) const |
| Retrieves the neighbor list for a specific atom. | |
| std::span< const AtomID > | getNeighborIndices (size_t atom_index) const |
| Retrieves a lightweight index-only view of neighbors for a specific atom. | |
| bool | areConnected (AtomIndex first_atom, AtomIndex second_atom) const |
| Checks if two atoms are connected by an edge using binary search. | |
| std::vector< bool > | getDenseAdjacencyMatrix () const |
| Generates a flattened dense adjacency matrix. | |
| size_t | nodeCount () const noexcept |
| size_t | edgeCount () const noexcept |
| std::span< const size_t > | offsets () const noexcept |
| std::span< const AtomID > | targets () const noexcept |
| std::span< const Neighbor > | neighbors () const noexcept |
Private Member Functions | |
| NeighborGraph (const std::scoped_lock< std::mutex > &, const NeighborGraph &other) | |
| NeighborGraph (const std::scoped_lock< std::mutex > &, NeighborGraph &other) noexcept | |
| void | ensureFinalized () const |
Private Attributes | |
| size_t | node_count_ {0} |
| std::atomic< bool > | is_finalized_ {true} |
| std::mutex | finalize_mutex_ |
| std::vector< Edge > | unfinalized_edges_ |
| std::vector< size_t > | offsets_ {0} |
| std::vector< Neighbor > | neighbors_ |
| std::vector< AtomID > | targets_ |
Compressed Sparse Row (CSR) based graph representing atomic connectivity.
Stores bonds and neighbor interactions as directed edges with deterministic row sorting by (target_index, distance). Eliminates per-row vector allocations and provides lightweight index-only views for high-throughput traversals.
|
explicitdefault |
Default constructor.


|
explicit |
Constructs a graph with a fixed number of nodes.
| node_count | The total number of atoms/nodes in the graph. |
| correlation::core::NeighborGraph::NeighborGraph | ( | const NeighborGraph & | other | ) |
Copy constructor.
| other | The graph instance to copy from. |

|
noexcept |
Move constructor.
| other | The graph instance to move from. |

|
default |
Destructor.
|
private |

|
privatenoexcept |

|
inline |
Adds a directed edge between two atoms using individual parameters.
| source | Index of the source atom. |
| target | Index of the target atom. |
| distance | Separation distance (Angstrom). |
| r_ij | Relative position vector from source to target. |

| void correlation::core::NeighborGraph::addDirectedEdge | ( | const Edge & | edge | ) |
Adds a directed edge between two atoms.
| edge | The directed edge details containing source, target, distance, and vector. |


|
nodiscard |
Checks if two atoms are connected by an edge using binary search.
| first_atom | First atom index. |
| second_atom | Second atom index. |

| void correlation::core::NeighborGraph::assignCSR | ( | size_t | node_count, |
| std::vector< size_t > | offsets, | ||
| std::vector< Neighbor > | neighbors, | ||
| std::vector< AtomID > | targets ) |
Directly assigns Compressed Sparse Row (CSR) storage.
| node_count | Number of nodes. |
| offsets | Row offsets array of size node_count + 1. |
| neighbors | Flat neighbors array of size offsets.back(). |
| targets | Flat target indices array of size offsets.back(). |

|
nodiscardnoexcept |

|
private |


| void correlation::core::NeighborGraph::finalize | ( | ) | const |
Finalizes the graph into Compressed Sparse Row (CSR) storage.
Sorts all neighbor rows by (index, distance) deterministically. Automatically invoked before queries if edges have been modified.

|
nodiscard |
Generates a flattened dense adjacency matrix.

|
nodiscard |
Retrieves a lightweight index-only view of neighbors for a specific atom.
| atom_index | Index of the atom. |


|
nodiscard |
Retrieves the neighbor list for a specific atom.
| atom_index | Index of the atom. |


|
nodiscardnoexcept |


|
nodiscardnoexcept |

|
nodiscardnoexcept |


| NeighborGraph & correlation::core::NeighborGraph::operator= | ( | const NeighborGraph & | other | ) |
Copy assignment operator.
| other | The graph instance to copy from. |

|
noexcept |
Move assignment operator.
| other | The graph instance to move from. |

|
nodiscardnoexcept |


|
mutableprivate |
|
mutableprivate |
|
mutableprivate |
|
private |
|
mutableprivate |
|
mutableprivate |
|
mutableprivate |