namespace primitive#

Overview#

Functions for generating primitive rings. More…

namespace primitive {
 
// enums
 
enum RingRows;
 
// structs
 
struct Graph;
struct RingSearchSplit;
struct Vertex;
 
// classes
 
class RingUpdater;
 
// global functions
 
std::vector<std::vector<int>> ringNetwork(const std::vector<std::vector<int>>& nList, int maxDepth);
std::vector<int> atomRingSizeCounts(const std::vector<std::vector<int>>& nList, int maxDepth);
std::vector<std::vector<int>> ringNetworkMinSize(const std::vector<std::vector<int>>& nList, int maxDepth, int minDepth);
std::vector<std::vector<int>> ringNetwork(const std::vector<std::vector<int>>& nList, int maxDepth, RingRows rows);
std::vector<std::vector<int>> ringNetwork(const std::vector<std::vector<int>>& nList, int maxDepth, const std::vector<char>& sources);
std::vector<std::vector<int>> ringNetwork(const std::vector<int>& offsets, const std::vector<int>& cols, int maxDepth, const std::vector<char>& sources = {});
std::vector<std::vector<int>> ringNetworkSymmetrized(const std::vector<int>& offsets, const std::vector<int>& cols, int maxDepth);
std::vector<int> ringSizeHistogram(const std::vector<std::vector<int>>& rings, int maxDepth);
void ringSizeCounts(const std::vector<int>& offsets, const std::vector<int>& cols, int maxDepth, int* counts, int countsLen);
std::vector<std::vector<int>> ringNetworkBalls(const std::vector<std::vector<int>>& nList, int maxDepth);
int lastRingSearchUsedBalls();
Graph populateGraphFromNListID(molSys::PointCloud<molSys::Point<double>, double>& yCloud, const std::vector<std::vector<int>>& neighHbondList);
Graph populateGraphFromIndices(const std::vector<std::vector<int>>& nList);
void restoreEdgesFromIndices(Graph& fullGraph, const std::vector<std::vector<int>>& nList);
Graph countAllRingsFromIndex(const std::vector<std::vector<int>>& neighHbondList, int maxDepth);
void removeNonSPrings(Graph& fullGraph);
int findRings(Graph& fullGraph, int v, std::vector<int>& visited, int maxDepth, int depth, int root = -1);
int shortestPath(Graph& fullGraph, int v, int goal, std::vector<int>& path, std::vector<int>& visited, int maxDepth, int depth = 1);
Graph clearGraph(Graph& currentGraph);
RingSearchSplit lastRingSearchSplit();
void setPhaseTiming(bool on);
double takePrimitiveMs();
void setSourceWork(double* microseconds);
 
} // namespace primitive

Detailed Documentation#

Functions for generating primitive rings.

This namespace contains struct definitions and functions that are used for generating primitive (shortest-path) rings (directed cyclic graphs).

The Vertex object is a collection of elements for each point, required for graph traversal. The Graph object is an object for the whole frame, containing the information of all vertices, and a row-ordered vector of vector of the rings generated.

The Franzblau shortest-path criterion has been used. The SP (shortest-path) criterion is midway between the least restrictive and most restrictive criteria in the hierarchy.

The following is the procedure for finding primitive rings:

  1. All possible rings (including non-SP) rings are found, in the primitive::countAllRingsFromIndex function, using the backtracking algorithm. This is a recursive algorithm.

  2. The non-SP rings are then removed from the list of all rings, using the Franzblau shortest path criterion (primitive::removeNonSPrings), answered by a hop-bounded breadth-first sweep per vertex.

Changelog#

Global Functions#

std::vector<std::vector<int>> ringNetwork(const std::vector<std::vector<int>>& nList, int maxDepth)

Returns a vector of vectors containing the rings (of all sizes), by atom index, given the neighbour list also by index (preferably the hydrogen-bonded neighbour list). Each ring starts at its lowest-indexed member and runs toward the lesser of that member’s ring neighbours, and the rings are sorted lexicographically.

std::vector<int> atomRingSizeCounts(const std::vector<std::vector<int>>& nList, int maxDepth)

Per-atom primitive-ring counts, without storing the rings. counts[atom * (maxDepth + 1) + size] is how many rings of that size contain the atom.

std::vector<std::vector<int>> ringNetworkMinSize(const std::vector<std::vector<int>>& nList, int maxDepth, int minDepth)

Primitive rings whose size is at least minDepth and at most maxDepth. ringNetwork(nList, maxDepth) is minDepth 3. A separate name keeps ringNetwork(nList, maxDepth, {}) the empty source mask.

std::vector<std::vector<int>> ringNetwork(const std::vector<std::vector<int>>& nList, int maxDepth, const std::vector<char>& sources)

The rings ringNetwork returns whose lowest-indexed member is flagged in sources (by index; empty flags every vertex), in the same order

std::vector<std::vector<int>> ringNetwork(const std::vector<int>& offsets, const std::vector<int>& cols, int maxDepth, const std::vector<char>& sources = {})

Rings of a CSR neighbour graph. cols[offsets[i] .. offsets[i + 1]] are the neighbours of vertex i, with no self entry. The ring set is the one ringNetwork returns for those rows with the vertex written in front of each row.

std::vector<std::vector<int>> ringNetworkSymmetrized(const std::vector<int>& offsets, const std::vector<int>& cols, int maxDepth)

Primitive rings of an explicit caller graph after converting every directed edge to one undirected edge. Self edges and duplicate columns are ignored. Throws std::invalid_argument for malformed CSR or an out-of-range column. The search itself is ringNetwork(offsets, cols, maxDepth).

std::vector<int> ringSizeHistogram(const std::vector<std::vector<int>>& rings, int maxDepth)

Histogram of a ring list. counts[s] is the number of size-s rings. The returned vector has maxDepth + 1 entries.

void ringSizeCounts(const std::vector<int>& offsets, const std::vector<int>& cols, int maxDepth, int* counts, int countsLen)

Ring sizes of the same search as ringNetwork(offsets, cols, maxDepth). counts[s] is the number of primitive rings of size s, for s below countsLen. The rings themselves are not gathered.

std::vector<std::vector<int>> ringNetworkBalls(const std::vector<std::vector<int>>& nList, int maxDepth)

The same ring set, built with a bounded ball at every vertex and a primitivity test of every pair. ringNetwork leaves that table out when the largest ring is at most 7, because a strict shortcut is then a walk of at most two edges. The timing harness compares the two.

int lastRingSearchUsedBalls()

0 when the last ringNetwork call answered every primitivity query from the adjacency rows, 1 when it filled the sorted pair table, 2 when it filled the occupancy bitset of a radius-4 ball, 3 when a radius-2 pair table answers distance 4 by a meet in the middle. Rings of size at most 7 report 0. Rings of size 8 and 9 report 1. Rings of size 10 report 3. ringNetworkBalls always reports 1.

Graph populateGraphFromNListID(molSys::PointCloud<molSys::Point<double>, double>& yCloud, const std::vector<std::vector<int>>& neighHbondList)

Creates a graph object and fills it with the information from a neighbour list and pointCloud created before. NOTE: the neighbourListIndex contains the indices and NOT the atom IDs as in the neighbour list

Graph populateGraphFromIndices(const std::vector<std::vector<int>>& nList)

Creates a graph object and fills it with the information from a neighbour list of INDICES NOT ATOM IDs created before. NOTE: the neighbourListIndex contains the indices and NOT the atom IDs as in the neighbour list

void restoreEdgesFromIndices(Graph& fullGraph, const std::vector<std::vector<int>>& nList)

Re-fills the neighbour lists of a graph object from a neighbour list of INDICES NOT ATOM IDs created before. NOTE: the neighbourListIndex contains the indices and NOT the atom IDs as in the neighbour list

Graph countAllRingsFromIndex(const std::vector<std::vector<int>>& neighHbondList, int maxDepth)

Creates a vector of vectors of all possible rings.

void removeNonSPrings(Graph& fullGraph)

Removes the non-SP rings, using the Franzblau shortest path criterion.

int findRings(Graph& fullGraph, int v, std::vector<int>& visited, int maxDepth, int depth, int root = -1)

Main function that searches for all rings.

int shortestPath(Graph& fullGraph, int v, int goal, std::vector<int>& path, std::vector<int>& visited, int maxDepth, int depth = 1)

Calculates the shortest path.

Graph clearGraph(Graph& currentGraph)

Function for clearing vectors in Graph after multiple usage.

RingSearchSplit lastRingSearchSplit()

Balls, source enumeration and the gather from the last ringNetwork call.

void setPhaseTiming(bool on)

When set, ringNetwork records the primitive-test time in the split.

double takePrimitiveMs()

Primitive-test milliseconds from the last timed ringNetwork, then zero.

void setSourceWork(double* microseconds)

When non-null, ringNetwork adds each source’s enumeration time, in microseconds, at that source’s index. The buffer must hold one entry per neighbour-list row. A null buffer skips the clock.