Molassembler  1.0.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Scine::Molassembler::Graph Class Reference

Represents the connectivity of atoms of a molecule. More...

#include <Graph.h>

Data Structures

class  InnerBasedIterator
 Templated iterator facade based on PrivateGraph to provide iterative access to atom indices and edge indices. More...
 

Public Types

Member types
using AtomIterator = InnerBasedIterator< AtomIndex, false >
 Iterator type yielding all valid atom indices.
 
using BondIterator = InnerBasedIterator< BondIndex, false >
 Iterator type yielding all valid bond indices.
 
using AdjacencyIterator = InnerBasedIterator< AtomIndex, true >
 Iterator type yielding adjacent atoms to an atom.
 
using IncidentEdgesIterator = InnerBasedIterator< BondIndex, true >
 Iterator type yielding incident bonds to an atom.
 

Public Member Functions

PrivateGraphinner ()
 Access to library-internal graph representation class. More...
 
const PrivateGraphinner () const
 Const-access to library-internal graph representation class. More...
 
Special member functions
 Graph (Graph &&other) noexcept
 
Graphoperator= (Graph &&other) noexcept
 
 Graph (const Graph &other)
 
Graphoperator= (const Graph &other)
 
 ~Graph ()
 
Constructors
 Graph ()
 Wrapping constructor.
 
 Graph (PrivateGraph &&inner)
 Wrapping constructor.
 
Information
bool adjacent (AtomIndex a, AtomIndex b) const
 Returns whether two atoms are bonded. More...
 
std::vector< AtomIndexatomsOfElement (Utils::ElementType e) const
 Returns atoms matching an element type. More...
 
boost::optional< BondIndexbond (AtomIndex a, AtomIndex b) const
 Optionally fetch the bond index of a possibly non-existent bond. More...
 
Utils::BondOrderCollection bondOrders () const
 Generate a BondOrderCollection from the graph. More...
 
BondType bondType (const BondIndex &edge) const
 Fetch the bond type at a particular bond. More...
 
bool canRemove (AtomIndex a) const
 Returns whether an atom can be removed without disconnecting the graph. More...
 
bool canRemove (const BondIndex &edge) const
 Returns whether a bond can be removed without disconnecting the graph. More...
 
const Cyclescycles () const
 Fetch a reference to Cycles. More...
 
unsigned degree (AtomIndex a) const
 Returns the number of bonds incident upon an atom. More...
 
std::string dumpGraphviz () const
 Dumps a graphviz representation of the graph.
 
Utils::ElementTypeCollection elementCollection () const
 Fetch an element collection of all atoms. More...
 
Utils::ElementType elementType (AtomIndex a) const
 Fetch the element type of an atom. More...
 
AtomIndex N () const
 Number of atoms in the graph. More...
 
unsigned B () const
 Number of bonds in the graph. More...
 
boost::optional< std::vector
< AtomIndex > > 
modularIsomorphism (const Graph &other, AtomEnvironmentComponents components=AtomEnvironmentComponents::All) const
 Modular isomorphism comparison. More...
 
std::pair< std::vector
< AtomIndex >, std::vector
< AtomIndex > > 
splitAlongBridge (BondIndex bridge) const
 Determine which vertices belong to which side of a bridge edge. More...
 
Operators
bool operator== (const Graph &other) const
 Full isomorphism comparison including element types and bond orders.
 
bool operator!= (const Graph &other) const
 Full isomorphism comparison including element types and bond orders.
 
Ranges
IteratorRange< AtomIteratoratoms () const
 A begin-end pair of iterators that yield the range of valid atom indices. More...
 
IteratorRange< BondIteratorbonds () const
 A begin-end pair of iterators that yield the range of valid bond indices. More...
 
IteratorRange< AdjacencyIteratoradjacents (AtomIndex a) const
 Fetch iterator pair yielding adjacents of an atom. More...
 
IteratorRange
< IncidentEdgesIterator
bonds (AtomIndex a) const
 Fetch iterator pair yielding bonds indices indicent to an atom. More...
 

Private Attributes

std::unique_ptr< PrivateGraphinnerPtr_
 

Detailed Description

Represents the connectivity of atoms of a molecule.

An undirected graph consisting of atom vertices and bond edges. Vertices store the atomic element type while vertices store a bond type that distinguishes the bond orders one through six as well as a so-called eta bond, which models connections between a central atom and a haptically-bonded subset of atoms (i.e. a contiguous group of atoms all bonded to a transition metal).

The Graph class leaves a consumer a lot of freedom in the specification of the molecule's graph, but does enforce some model limitations.

  • A molecule's graph must consist of a single connected component, meaning that there must be a path from any atom of the molecule to any other.
  • Single atoms are not considered molecules, so a molecule must consist of at least two mutually bonded atoms.
  • Removing atoms or bonds from diatomic molecules are disallowed operations.
  • Disconnecting a molecule into two logical molecules by removing a particular bond or atom is also disallowed.
Note
This class wraps PrivateGraph so that no Boost Graph types are exposed to library consumers.

Member Function Documentation

bool Scine::Molassembler::Graph::adjacent ( AtomIndex  a,
AtomIndex  b 
) const

Returns whether two atoms are bonded.

Complexity \(\Theta(1)\)

IteratorRange<AdjacencyIterator> Scine::Molassembler::Graph::adjacents ( AtomIndex  a) const

Fetch iterator pair yielding adjacents of an atom.

Parameters
aThe atom whose adjacents are desired

Complexity \(\Theta(N)\)

Returns
A begin-end pair of iterators that yield adjacent atoms of an atom
IteratorRange<AtomIterator> Scine::Molassembler::Graph::atoms ( ) const

A begin-end pair of iterators that yield the range of valid atom indices.

Complexity \(\Theta(N)\)

std::vector<AtomIndex> Scine::Molassembler::Graph::atomsOfElement ( Utils::ElementType  e) const

Returns atoms matching an element type.

Complexity \(\Theta(N)\)

unsigned Scine::Molassembler::Graph::B ( ) const

Number of bonds in the graph.

Complexity \(\Theta(1)\)

boost::optional<BondIndex> Scine::Molassembler::Graph::bond ( AtomIndex  a,
AtomIndex  b 
) const

Optionally fetch the bond index of a possibly non-existent bond.

Complexity \(\Theta(1)\)

Utils::BondOrderCollection Scine::Molassembler::Graph::bondOrders ( ) const

Generate a BondOrderCollection from the graph.

Complexity \(\Theta(B)\)

IteratorRange<BondIterator> Scine::Molassembler::Graph::bonds ( ) const

A begin-end pair of iterators that yield the range of valid bond indices.

Complexity \(\Theta(N)\)

IteratorRange<IncidentEdgesIterator> Scine::Molassembler::Graph::bonds ( AtomIndex  a) const

Fetch iterator pair yielding bonds indices indicent to an atom.

Parameters
aThe atom whose incident atoms are desired

Complexity \(\Theta(N)\)

Returns
A begin-end pair of iterators that yield incident bond indices of an atom
BondType Scine::Molassembler::Graph::bondType ( const BondIndex edge) const

Fetch the bond type at a particular bond.

Complexity \(\Theta(1)\)

bool Scine::Molassembler::Graph::canRemove ( AtomIndex  a) const

Returns whether an atom can be removed without disconnecting the graph.

Complexity \(O(N)\) worst case, if removal data is cached \(\Theta(1)\)

Note
This function is not thread-safe.
bool Scine::Molassembler::Graph::canRemove ( const BondIndex edge) const

Returns whether a bond can be removed without disconnecting the graph.

Complexity \(O(N)\) worst case, if removal data is cached \(\Theta(1)\)

Note
This function is not thread-safe.
const Cycles& Scine::Molassembler::Graph::cycles ( ) const

Fetch a reference to Cycles.

Complexity \(O(B)\) worst case where \(B\) is the number of bonds in cycles, if cycles are cached \(\Theta(1)\)

Note
This function is not thread-safe.
unsigned Scine::Molassembler::Graph::degree ( AtomIndex  a) const

Returns the number of bonds incident upon an atom.

Complexity \(\Theta(1)\)

Utils::ElementTypeCollection Scine::Molassembler::Graph::elementCollection ( ) const

Fetch an element collection of all atoms.

Complexity \(\Theta(N)\)

Utils::ElementType Scine::Molassembler::Graph::elementType ( AtomIndex  a) const

Fetch the element type of an atom.

Complexity \(\Theta(1)\)

PrivateGraph& Scine::Molassembler::Graph::inner ( )

Access to library-internal graph representation class.

Complexity \(\Theta(1)\)

Warning
This function is not intended for library consumers, merely used for implementation purposes.
const PrivateGraph& Scine::Molassembler::Graph::inner ( ) const

Const-access to library-internal graph representation class.

Complexity \(\Theta(1)\)

Warning
This function is not intended for library consumers, merely used for implementation purposes.
boost::optional<std::vector<AtomIndex> > Scine::Molassembler::Graph::modularIsomorphism ( const Graph other,
AtomEnvironmentComponents  components = AtomEnvironmentComponents::All 
) const

Modular isomorphism comparison.

Returns None if the molecules are not isomorphic. Returns an index mapping from this to other otherwise.

AtomIndex Scine::Molassembler::Graph::N ( ) const

Number of atoms in the graph.

Complexity \(\Theta(1)\)

std::pair< std::vector<AtomIndex>, std::vector<AtomIndex> > Scine::Molassembler::Graph::splitAlongBridge ( BondIndex  bridge) const

Determine which vertices belong to which side of a bridge edge.

Complexity \(\Theta(N)\)

The atoms making up the bond are in the resulting atom lists, too.

Note
This function is not thread-safe.

The documentation for this class was generated from the following file: