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

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

#include <Graph.h>

Inheritance diagram for Scine::Molassembler::Graph:

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 () final
 
Constructors
 Graph ()
 Wrapping constructor.
 
 Graph (PrivateGraph &&inner)
 Wrapping constructor.
 
Modification
AtomIndex addAtom (Utils::ElementType e, AtomIndex i, BondType type) final
 
BondIndex addBond (AtomIndex i, AtomIndex j, BondType type) final
 
void setElementType (AtomIndex i, Utils::ElementType type) final
 
bool setBondType (AtomIndex i, AtomIndex j, BondType type) final
 
void removeAtom (AtomIndex i) final
 
void removeBond (const BondIndex &bond) final
 
Information
bool adjacent (AtomIndex a, AtomIndex b) const final
 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 final
 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 final
 Fetch the bond type at a particular bond. More...
 
bool canRemove (AtomIndex a) const final
 Returns whether an atom can be removed without disconnecting the graph. More...
 
bool canRemove (const BondIndex &edge) const final
 Returns whether a bond can be removed without disconnecting the graph. More...
 
const Cyclescycles () const final
 Fetch a reference to Cycles. More...
 
unsigned degree (AtomIndex a) const final
 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 final
 Fetch the element type of an atom. More...
 
AtomIndex N () const
 Number of atoms in the graph. More...
 
AtomIndex V () const final
 Number of atoms in the graph. More...
 
unsigned B () const
 Number of bonds in the graph. More...
 
unsigned E () const final
 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...
 
Modification
Information

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
finalvirtual

Returns whether two atoms are bonded.

Complexity \(\Theta(1)\)

Implements Scine::Molassembler::GraphInterface.

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(V)\)

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(V)\)

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

Returns atoms matching an element type.

Complexity \(\Theta(V)\)

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
finalvirtual

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

Complexity \(\Theta(1)\)

Implements Scine::Molassembler::GraphInterface.

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

Generate a BondOrderCollection from the graph.

Complexity \(\Theta(E)\)

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

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

Complexity \(\Theta(V)\)

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(V)\)

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

Fetch the bond type at a particular bond.

Complexity \(\Theta(1)\)

Implements Scine::Molassembler::GraphInterface.

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

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

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

Note
This function is not thread-safe.

Implements Scine::Molassembler::GraphInterface.

bool Scine::Molassembler::Graph::canRemove ( const BondIndex edge) const
finalvirtual

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

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

Note
This function is not thread-safe.

Implements Scine::Molassembler::GraphInterface.

const Cycles& Scine::Molassembler::Graph::cycles ( ) const
finalvirtual

Fetch a reference to Cycles.

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

Note
This function is not thread-safe.

Implements Scine::Molassembler::GraphInterface.

unsigned Scine::Molassembler::Graph::degree ( AtomIndex  a) const
finalvirtual

Returns the number of bonds incident upon an atom.

Complexity \(\Theta(1)\)

Implements Scine::Molassembler::GraphInterface.

unsigned Scine::Molassembler::Graph::E ( ) const
finalvirtual

Number of bonds in the graph.

Complexity \(\Theta(1)\)

Implements Scine::Molassembler::GraphInterface.

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

Fetch an element collection of all atoms.

Complexity \(\Theta(V)\)

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

Fetch the element type of an atom.

Complexity \(\Theta(1)\)

Implements Scine::Molassembler::GraphInterface.

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(V)\)

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

Note
This function is not thread-safe.
AtomIndex Scine::Molassembler::Graph::V ( ) const
finalvirtual

Number of atoms in the graph.

Complexity \(\Theta(1)\)

Implements Scine::Molassembler::GraphInterface.


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