Loading...
Searching...
No Matches
topo Namespace Reference

Classes

struct  LocalKey
struct  FrameFingerprint
struct  KeyLibrary
 A dictionary from local keys to labels: the keys of reference structures (a polymorph library), so any molecule whose rooted neighbourhood matches a reference gets that reference's name. More...
struct  LibraryMatch

Typedefs

using Rows = std::vector<std::vector<int>>
 Neighbour rows by index, each row leading with the atom itself, as nneigh::neighbourListByIndex returns them.

Functions

std::vector< int > hopNeighbourhood (const Rows &rows, int atom, int hops)
 Atoms within hops bonds of atom, the atom itself first, then in breadth-first order.
std::uint64_t wlHash (const std::vector< std::vector< int > > &adjacency, int root, int rounds, const std::vector< int > &colours={})
 Weisfeiler-Lehman refinement hash of a graph given by local adjacency lists; root (or -1) starts in its own colour; colours (empty or one integer per vertex, such as the atom type) seeds the initial colours.
LocalKey localKey (const Rows &rows, int atom, int hops, const std::vector< int > &colours={})
 Key of the rooted neighbourhood of atom.
FrameFingerprint fingerprint (const Rows &rows, int hops=2, int maxRingSize=7, const std::vector< int > &colours={})
 Keys of every atom, their histogram, the ring census up to maxRingSize, and the frame key.
FrameFingerprint incrementalFingerprint (const FrameFingerprint &prev, const Rows &rows, const std::vector< int > &dirtyAtoms, int hops, int maxRingSize=7, const std::vector< int > &colours={})
 Recompute local keys only for the hop-ball of dirtyAtoms and keep the rest of prev.
std::string hex (std::uint64_t value)
 Hex string of a 64-bit hash.
void addToLibrary (KeyLibrary &lib, const FrameFingerprint &fp, const std::string &label)
 Add every distinct key of fp under label; a key already present under other labels carries all of them, sorted and joined by '|'.
std::string writeLibrary (const KeyLibrary &lib)
 Text form: a header line # method M hops H colours C (C is 0 or 1; a header without it means uncoloured), then key label lines.
KeyLibrary readLibrary (const std::string &text)
LibraryMatch matchLibrary (const FrameFingerprint &fp, const KeyLibrary &lib)
 Look every atom key of fp up in lib.
LibraryMatch matchLibraries (const Rows &rows, const std::vector< KeyLibrary > &libs, int maxRingSize=7, const std::vector< int > &colours={})
 Match against libraries at several depths: an atom takes the label of the deepest library that holds its key, and a molecule whose wide neighbourhood is disturbed (a defect two bonds away, a jittered dense polymorph) still gets named by its inner shells.

Typedef Documentation

◆ Rows

using topo::Rows = std::vector<std::vector<int>>

Neighbour rows by index, each row leading with the atom itself, as nneigh::neighbourListByIndex returns them.

Definition at line 38 of file topo_fingerprint.hpp.

Function Documentation

◆ addToLibrary()

void topo::addToLibrary ( KeyLibrary & lib,
const FrameFingerprint & fp,
const std::string & label )

Add every distinct key of fp under label; a key already present under other labels carries all of them, sorted and joined by '|'.

◆ fingerprint()

FrameFingerprint topo::fingerprint ( const Rows & rows,
int hops = 2,
int maxRingSize = 7,
const std::vector< int > & colours = {} )

Keys of every atom, their histogram, the ring census up to maxRingSize, and the frame key.

colours as in localKey.

◆ hex()

std::string topo::hex ( std::uint64_t value)

Hex string of a 64-bit hash.

◆ hopNeighbourhood()

std::vector< int > topo::hopNeighbourhood ( const Rows & rows,
int atom,
int hops )

Atoms within hops bonds of atom, the atom itself first, then in breadth-first order.

◆ incrementalFingerprint()

FrameFingerprint topo::incrementalFingerprint ( const FrameFingerprint & prev,
const Rows & rows,
const std::vector< int > & dirtyAtoms,
int hops,
int maxRingSize = 7,
const std::vector< int > & colours = {} )

Recompute local keys only for the hop-ball of dirtyAtoms and keep the rest of prev.

The ring census is taken on rows. A size or hop mismatch falls back to a full fingerprint.

◆ localKey()

LocalKey topo::localKey ( const Rows & rows,
int atom,
int hops,
const std::vector< int > & colours = {} )

Key of the rooted neighbourhood of atom.

colours is empty or one class per row (atom type, species); coloured vertices never match vertices of another colour.

◆ matchLibraries()

LibraryMatch topo::matchLibraries ( const Rows & rows,
const std::vector< KeyLibrary > & libs,
int maxRingSize = 7,
const std::vector< int > & colours = {} )

Match against libraries at several depths: an atom takes the label of the deepest library that holds its key, and a molecule whose wide neighbourhood is disturbed (a defect two bonds away, a jittered dense polymorph) still gets named by its inner shells.

depth records the hops that named each atom. Every library must share the method of this build and the colouring (colours empty or one per row); throws std::invalid_argument otherwise, or when two libraries share a depth.

◆ matchLibrary()

LibraryMatch topo::matchLibrary ( const FrameFingerprint & fp,
const KeyLibrary & lib )

Look every atom key of fp up in lib.

Throws std::invalid_argument when the methods, hop counts or colourings differ.

◆ readLibrary()

KeyLibrary topo::readLibrary ( const std::string & text)

◆ wlHash()

std::uint64_t topo::wlHash ( const std::vector< std::vector< int > > & adjacency,
int root,
int rounds,
const std::vector< int > & colours = {} )

Weisfeiler-Lehman refinement hash of a graph given by local adjacency lists; root (or -1) starts in its own colour; colours (empty or one integer per vertex, such as the atom type) seeds the initial colours.

rounds refinements.

◆ writeLibrary()

std::string topo::writeLibrary ( const KeyLibrary & lib)

Text form: a header line # method M hops H colours C (C is 0 or 1; a header without it means uncoloured), then key label lines.