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

Library internal graph class wrapping BGL types. More...

#include <PrivateGraph.h>

Data Structures

struct  EdgeData
 Information stored at each graph edge. More...
 
struct  Properties
 
struct  RemovalSafetyData
 Data class to return removal safety information on the graph. More...
 
struct  VertexData
 Information stored at each graph vertex. More...
 

Public Types

Member types
using BglType = boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, VertexData, EdgeData >
 
using Vertex = BglType::vertex_descriptor
 
using Edge = BglType::edge_descriptor
 
using VertexRange = IteratorRange< BglType::vertex_iterator >
 
using EdgeRange = IteratorRange< BglType::edge_iterator >
 
using AdjacentVertexRange = IteratorRange< BglType::adjacency_iterator >
 
using IncidentEdgeRange = IteratorRange< BglType::out_edge_iterator >
 

Public Member Functions

Constructors
 PrivateGraph ()
 Empty constructor.
 
 PrivateGraph (Vertex N)
 Preallocating constructor.
 
Rule of five members
 PrivateGraph (const PrivateGraph &other)
 
 PrivateGraph (PrivateGraph &&other)
 
PrivateGraphoperator= (const PrivateGraph &other)
 
PrivateGraphoperator= (PrivateGraph &&other)
 
 ~PrivateGraph ()
 
Modification
Edge addEdge (Vertex a, Vertex b, BondType bondType)
 Add an edge to the graph. More...
 
Vertex addVertex (Utils::ElementType elementType)
 Add a (disconnected) vertex to the graph. More...
 
void applyPermutation (const std::vector< Vertex > &permutation)
 Apply a permutation to the graph. More...
 
BondTypebondType (const Edge &edge)
 Fetch the bond type of an edge. More...
 
BglTypebgl ()
 Referential access to the underlying BGL graph.
 
void clearVertex (Vertex a)
 Removes all bonds involving a vertex. More...
 
Utils::ElementType & elementType (Vertex a)
 Fetches the element type of a vertex. More...
 
void removeEdge (const Edge &e)
 Removes an edge from the graph. More...
 
void removeVertex (Vertex a)
 Removes a vertex from the graph. More...
 
Information
Utils::ElementType elementType (Vertex a) const
 Fetches the element type of a vertex. More...
 
BondType bondType (const Edge &edge) const
 Fetch the bond type of an edge. More...
 
const BglTypebgl () const
 Nonmodifiable access to the underlying BGL graph.
 
bool canRemove (Vertex a) const
 Determine whether a vertex can be safely removed. More...
 
bool canRemove (const Edge &edge) const
 Determine whether an edge can be safely removed An edge can be safely removed if it is not a bridge edge. More...
 
unsigned connectedComponents () const
 Number of connected components. More...
 
unsigned connectedComponents (std::vector< unsigned > &componentMap) const
 Connected components, yielding a map from vertices to component index. More...
 
Edge edge (Vertex a, Vertex b) const
 Make an edge descriptor from two vertex descriptors. More...
 
boost::optional< EdgeedgeOption (Vertex a, Vertex b) const
 Get an edge descriptor from two vertex descriptors, get None if the edge doesn't exist. More...
 
Vertex source (const Edge &edge) const
 Source of an edge.
 
Vertex target (const Edge &edge) const
 Target of an edge.
 
Vertex degree (Vertex a) const
 Number of substituents of a vertex. More...
 
Vertex N () const
 Number of vertices in the graph.
 
Vertex B () const
 Number of edges in the graph.
 
boost::optional< std::vector
< AtomIndex > > 
modularIsomorphism (const PrivateGraph &other, AtomEnvironmentComponents components=AtomEnvironmentComponents::All) const
 Modular isomorphism comparison. More...
 
bool identicalGraph (const PrivateGraph &other) const
 Checks whether all edges present in *this are present in other. More...
 
std::pair< std::vector
< AtomIndex >, std::vector
< AtomIndex > > 
splitAlongBridge (Edge bridge) const
 Determine which vertices belong to which side of a bridge edge. More...
 
Cached properties access

Call complexity depends on whether the properties have been calculated before. After generation, properties are valid as long as no non-const method is called on this class that modifies state.

None of these methods are thread-safe.

void populateProperties () const
 Access cycle information of the graph.
 
const Cyclescycles () const
 Access cycle information of the graph.
 
const RemovalSafetyDataremovalSafetyData () const
 Access removal safety information of the graph.
 
const CyclesetaPreservedCycles () const
 Access cycle information of the graph with eta bonds preserved.
 
Ranges
VertexRange vertices () const
 
EdgeRange edges () const
 
AdjacentVertexRange adjacents (Vertex a) const
 
IncidentEdgeRange edges (Vertex a) const
 
Operators
bool operator== (const PrivateGraph &other) const
 Full isomorphism comparison including element types and bond orders.
 
bool operator!= (const PrivateGraph &other) const
 Full isomorphism comparison including element types and bond orders.
 

Static Public Attributes

Static members
static constexpr Vertex removalPlaceholder = std::numeric_limits<Vertex>::max()
 Placeholder vertex index used to indicate that a vertex has been removed.
 

Private Member Functions

Private types
RemovalSafetyData generateRemovalSafetyData_ () const
 
Cycles generateCycles_ () const
 
Cycles generateEtaPreservedCycles_ () const
 

Private Attributes

Private state
BglType graph_
 A directly owned Boost Library Graph.
 
Properties properties_
 Property caching.
 

Detailed Description

Library internal graph class wrapping BGL types.

Member Typedef Documentation

The type of the BGL graph.

An adjacency list is used due to sparsity of the molecular graph.

using Scine::Molassembler::PrivateGraph::BglType = boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, VertexData, EdgeData >

The type of the BGL graph.

An adjacency list is used due to sparsity of the molecular graph.

using Scine::Molassembler::PrivateGraph::Edge = BglType::edge_descriptor

The type of the BGL graph.

An adjacency list is used due to sparsity of the molecular graph.

The type of the BGL graph.

An adjacency list is used due to sparsity of the molecular graph.

The type of the BGL graph.

An adjacency list is used due to sparsity of the molecular graph.

using Scine::Molassembler::PrivateGraph::Vertex = BglType::vertex_descriptor

The type of the BGL graph.

An adjacency list is used due to sparsity of the molecular graph.

The type of the BGL graph.

An adjacency list is used due to sparsity of the molecular graph.

Member Function Documentation

Edge Scine::Molassembler::PrivateGraph::addEdge ( Vertex  a,
Vertex  b,
BondType  bondType 
)

Add an edge to the graph.

Complexity \(\Theta(1)\)

Exceptions
std::logic_errorif the edge already exists
Vertex Scine::Molassembler::PrivateGraph::addVertex ( Utils::ElementType  elementType)

Add a (disconnected) vertex to the graph.

Complexity \(\Theta(1)\)

void Scine::Molassembler::PrivateGraph::applyPermutation ( const std::vector< Vertex > &  permutation)

Apply a permutation to the graph.

Complexity \(\Theta(V)\)

BondType& Scine::Molassembler::PrivateGraph::bondType ( const Edge edge)

Fetch the bond type of an edge.

Complexity \(\Theta(1)\)

Precondition
The edge exists
BondType Scine::Molassembler::PrivateGraph::bondType ( const Edge edge) const

Fetch the bond type of an edge.

Complexity \(\Theta(1)\)

Precondition
The edge exists
bool Scine::Molassembler::PrivateGraph::canRemove ( Vertex  a) const

Determine whether a vertex can be safely removed.

A Vertex can be safely removed if it is not an articulation vertex or if the number of vertices is more than one.

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

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

Determine whether an edge can be safely removed An edge can be safely removed if it is not a bridge edge.

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

Note
This function is not thread-safe.
void Scine::Molassembler::PrivateGraph::clearVertex ( Vertex  a)

Removes all bonds involving a vertex.

Complexity \(\Theta(1)\)

unsigned Scine::Molassembler::PrivateGraph::connectedComponents ( ) const

Number of connected components.

Complexity \(\Theta(V)\)

unsigned Scine::Molassembler::PrivateGraph::connectedComponents ( std::vector< unsigned > &  componentMap) const

Connected components, yielding a map from vertices to component index.

Complexity \(\Theta(V)\)

Vertex Scine::Molassembler::PrivateGraph::degree ( Vertex  a) const

Number of substituents of a vertex.

Complexity \(\Theta(1)\)

Edge Scine::Molassembler::PrivateGraph::edge ( Vertex  a,
Vertex  b 
) const

Make an edge descriptor from two vertex descriptors.

Exceptions
std::out_of_rangeif the edge doesn't exist in the graph Complexity \(\Theta(1)\)
boost::optional<Edge> Scine::Molassembler::PrivateGraph::edgeOption ( Vertex  a,
Vertex  b 
) const

Get an edge descriptor from two vertex descriptors, get None if the edge doesn't exist.

Complexity \(\Theta(1)\)

Utils::ElementType& Scine::Molassembler::PrivateGraph::elementType ( Vertex  a)

Fetches the element type of a vertex.

Complexity \(\Theta(1)\)

Precondition
The vertex exists
Utils::ElementType Scine::Molassembler::PrivateGraph::elementType ( Vertex  a) const

Fetches the element type of a vertex.

Complexity \(\Theta(1)\)

Precondition
The vertex exists
bool Scine::Molassembler::PrivateGraph::identicalGraph ( const PrivateGraph other) const

Checks whether all edges present in *this are present in other.

Complexity \(O(B)\)

boost::optional<std::vector<AtomIndex> > Scine::Molassembler::PrivateGraph::modularIsomorphism ( const PrivateGraph 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.

void Scine::Molassembler::PrivateGraph::removeEdge ( const Edge e)

Removes an edge from the graph.

Complexity \(\Theta(1)\)

void Scine::Molassembler::PrivateGraph::removeVertex ( Vertex  a)

Removes a vertex from the graph.

Complexity \(\Theta(1)\)

Warning
This invalidates ALL vertex and edge descriptors!
std::pair< std::vector<AtomIndex>, std::vector<AtomIndex> > Scine::Molassembler::PrivateGraph::splitAlongBridge ( Edge  bridge) const

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

Complexity \(\Theta(N)\)

Note
This function is not thread-safe.

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