8 #ifndef INCLUDE_MOLASSEMBLER_INNER_GRAPH_H
9 #define INCLUDE_MOLASSEMBLER_INNER_GRAPH_H
11 #include "boost/graph/adjacency_list.hpp"
21 namespace Molassembler {
32 Utils::ElementType elementType;
70 using Vertex = BglType::vertex_descriptor;
71 using Edge = BglType::edge_descriptor;
183 std::unordered_map<Vertex, Vertex>
merge(
185 const std::vector<Vertex>& copyVertices = {}
271 [[deprecated(
"Prefer V")]]
274 [[deprecated(
"Prefer E")]]
304 std::vector<AtomIndex>,
305 std::vector<AtomIndex>
310 std::vector<AtomIndex>,
311 std::vector<AtomIndex>
346 return !(*
this == other);
354 boost::optional<RemovalSafetyData> removalSafetyDataOption;
355 boost::optional<Cycles> cyclesOption;
356 boost::optional<Cycles> etaPreservedCyclesOption;
358 inline void invalidate() {
359 removalSafetyDataOption = boost::none;
360 cyclesOption = boost::none;
361 etaPreservedCyclesOption = boost::none;
366 Cycles generateCycles_()
const;
367 Cycles generateEtaPreservedCycles_()
const;
Class to explore cyclic structure of molecules.
Wrapper class to make working with RDL in C++ more pleasant.
Definition: Cycles.h:44
Library internal graph class wrapping BGL types.
Definition: PrivateGraph.h:26
void clearVertex(Vertex a)
Removes all bonds involving a vertex.
std::string graphviz() const
Returns whether two vertices are adjacent.
Properties properties_
Property caching.
Definition: PrivateGraph.h:375
const RemovalSafetyData & removalSafetyData() const
Access removal safety information of the graph.
BglType & bgl()
Referential access to the underlying BGL graph.
BondType bondType(const Edge &edge) const
Fetch the bond type of an edge.
std::pair< std::vector< AtomIndex >, std::vector< AtomIndex > > splitAlongBridge(Edge bridge) const
Determine which vertices belong to which side of a bridge edge.
BondType & bondType(const Edge &edge)
Fetch the bond type of an edge.
unsigned degree(Vertex a) const
Number of substituents of a vertex.
std::unordered_map< Vertex, Vertex > merge(const PrivateGraph &other, const std::vector< Vertex > ©Vertices={})
Copy a vertices and edges into another graph.
bool identicalGraph(const PrivateGraph &other) const
Checks whether all edges present in *this are present in other.
const Cycles & cycles() const
Access cycle information of the graph.
unsigned connectedComponents() const
Number of connected components.
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.
boost::optional< std::vector< AtomIndex > > modularIsomorphism(const PrivateGraph &other, AtomEnvironmentComponents components=AtomEnvironmentComponents::All) const
Modular isomorphism comparison.
const Cycles & etaPreservedCycles() const
Access cycle information of the graph with eta bonds preserved.
void removeEdge(const Edge &e)
Removes an edge from the graph.
Utils::ElementType & elementType(Vertex a)
Fetches the element type of a vertex.
void removeVertex(Vertex a)
Removes a vertex from the graph.
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 e...
BglType::edge_descriptor Edge
Definition: PrivateGraph.h:71
bool operator==(const PrivateGraph &other) const
Full isomorphism comparison including element types and bond orders.
PrivateGraph()
Empty constructor.
Vertex target(const Edge &edge) const
Target of an edge.
Vertex V() const
Number of vertices in the graph.
BglType::vertex_descriptor Vertex
Definition: PrivateGraph.h:70
Edge addEdge(Vertex a, Vertex b, BondType bondType)
Add an edge to the graph.
static constexpr Vertex removalPlaceholder
Placeholder vertex index used to indicate that a vertex has been removed.
Definition: PrivateGraph.h:113
Vertex addVertex(Utils::ElementType elementType)
Add a (disconnected) vertex to the graph.
BglType graph_
A directly owned Boost Library Graph.
Definition: PrivateGraph.h:373
Vertex source(const Edge &edge) const
Source of an edge.
Vertex B() const
Number of edges in the graph.
bool adjacent(Vertex a, Vertex b) const
Returns whether two vertices are adjacent.
Utils::ElementTypeCollection elementCollection() const
Returns whether two vertices are adjacent.
boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, VertexData, EdgeData > BglType
Definition: PrivateGraph.h:68
Utils::ElementType elementType(Vertex a) const
Fetches the element type of a vertex.
PrivateGraph(Vertex N)
Preallocating constructor.
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.
bool operator!=(const PrivateGraph &other) const
Full isomorphism comparison including element types and bond orders.
Definition: PrivateGraph.h:345
unsigned connectedComponents(std::vector< unsigned > &componentMap) const
Connected components, yielding a map from vertices to component index.
Vertex N() const
Number of vertices in the graph.
Edge edge(Vertex a, Vertex b) const
Make an edge descriptor from two vertex descriptors.
void applyPermutation(const std::vector< Vertex > &permutation)
Apply a permutation to the graph.
const BglType & bgl() const
Nonmodifiable access to the underlying BGL graph.
bool canRemove(Vertex a) const
Determine whether a vertex can be safely removed.
unsigned E() const
Number of edges in the graph.
void populateProperties() const
Access cycle information of the graph.
AtomEnvironmentComponents
For bitmasks grouping components of immediate atom environments.
Definition: Types.h:103
BondType
Discrete bond type numeration.
Definition: Types.h:26
std::size_t AtomIndex
Unsigned integer atom index type. Used to refer to particular atoms.
Definition: Types.h:51
Homogeneous pair of iterators with begin and end member fns.
Definition: IteratorRange.h:26
Information stored at each graph edge.
Definition: PrivateGraph.h:36
Definition: PrivateGraph.h:353
Data class to return removal safety information on the graph.
Definition: PrivateGraph.h:85
std::unordered_set< PrivateGraph::Vertex > articulationVertices
Articulation vertices cannot be removed without disconnecting the graph.
Definition: PrivateGraph.h:87
std::set< PrivateGraph::Edge > bridges
Bridges are edges that cannot be removed without disconnecting the graph.
Definition: PrivateGraph.h:89
Information stored at each graph vertex.
Definition: PrivateGraph.h:31