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) | |
PrivateGraph & | operator= (const PrivateGraph &other) |
PrivateGraph & | operator= (PrivateGraph &&other) noexcept |
~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... | |
BondType & | bondType (const Edge &edge) |
Fetch the bond type of an edge. More... | |
BglType & | bgl () |
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... | |
std::unordered_map< Vertex, Vertex > | merge (const PrivateGraph &other, const std::vector< Vertex > ©Vertices={}) |
Copy a vertices and edges into another graph. More... | |
Information | |
bool | adjacent (Vertex a, Vertex b) const |
Returns whether two vertices are adjacent. | |
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 BglType & | bgl () 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< Edge > | edgeOption (Vertex a, Vertex b) const |
Get an edge descriptor from two vertex descriptors, get None if the edge doesn't exist. More... | |
Utils::ElementTypeCollection | elementCollection () const |
Returns whether two vertices are adjacent. | |
Vertex | source (const Edge &edge) const |
Source of an edge. | |
Vertex | target (const Edge &edge) const |
Target of an edge. | |
unsigned | degree (Vertex a) const |
Number of substituents of a vertex. More... | |
std::string | graphviz () const |
Returns whether two vertices are adjacent. | |
Vertex | N () const |
Number of vertices in the graph. | |
Vertex | B () const |
Number of edges in the graph. | |
Vertex | V () const |
Number of vertices in the graph. | |
unsigned | E () 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... | |
std::pair< std::vector < AtomIndex >, std::vector < AtomIndex > > | splitAlongBridge (AtomIndex left, const std::vector< AtomIndex > &right) const |
Determine which vertices belong to which side of a bridge edge. | |
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 Cycles & | cycles () const |
Access cycle information of the graph. | |
const RemovalSafetyData & | removalSafetyData () const |
Access removal safety information of the graph. | |
const Cycles & | etaPreservedCycles () 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. | |
Library internal graph class wrapping BGL types.
using Scine::Molassembler::PrivateGraph::AdjacentVertexRange = IteratorRange<BglType::adjacency_iterator> |
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.
using Scine::Molassembler::PrivateGraph::EdgeRange = IteratorRange<BglType::edge_iterator> |
The type of the BGL graph.
An adjacency list is used due to sparsity of the molecular graph.
using Scine::Molassembler::PrivateGraph::IncidentEdgeRange = IteratorRange<BglType::out_edge_iterator> |
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.
using Scine::Molassembler::PrivateGraph::VertexRange = IteratorRange<BglType::vertex_iterator> |
The type of the BGL graph.
An adjacency list is used due to sparsity of the molecular graph.
Add an edge to the graph.
Complexity \(\Theta(1)\)
std::logic_error | if 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)\)
Fetch the bond type of an edge.
Complexity \(\Theta(1)\)
Fetch the bond type of an edge.
Complexity \(\Theta(1)\)
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)\)
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)\)
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)\)
unsigned Scine::Molassembler::PrivateGraph::degree | ( | Vertex | a | ) | const |
Number of substituents of a vertex.
Complexity \(\Theta(1)\)
Make an edge descriptor from two vertex descriptors.
std::out_of_range | if the edge doesn't exist in the graph Complexity \(\Theta(1)\) |
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)\)
Utils::ElementType Scine::Molassembler::PrivateGraph::elementType | ( | Vertex | a | ) | const |
Fetches the element type of a vertex.
Complexity \(\Theta(1)\)
bool Scine::Molassembler::PrivateGraph::identicalGraph | ( | const PrivateGraph & | other | ) | const |
Checks whether all edges present in *this are present in other
.
Complexity \(O(E)\)
std::unordered_map<Vertex, Vertex> Scine::Molassembler::PrivateGraph::merge | ( | const PrivateGraph & | other, |
const std::vector< Vertex > & | copyVertices = {} |
||
) |
Copy a vertices and edges into another graph.
other | The source graph from which to copy |
copyVertices | List of vertices to copy. If empty, copies all vertices. |
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)\)
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(V)\)