IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
bond_graph.h
Go to the documentation of this file.
1/**
2 * \file IMP/atom/bond_graph.h
3 * \brief Represents a graph of the bonds within an atomic structure
4 *
5 * Copyright 2007-2022 IMP Inventors. All rights reserved.
6 *
7 */
8
9#ifndef IMPATOM_BOND_GRAPH_H
10#define IMPATOM_BOND_GRAPH_H
11
12#include "bond_decorators.h"
13#include "Hierarchy.h"
14#include "internal/bond_graph_functors.h"
16#include <IMP/internal/NestedIterator.h>
17#include <boost/graph/graph_traits.hpp>
18#include <boost/graph/properties.hpp>
19#include <boost/iterator/transform_iterator.hpp>
20
21#ifndef SWIG
22
23IMPATOM_BEGIN_NAMESPACE
24
25//! Represent a bond graph as a boost graph
26/** The BondGraph class implements the following boost graph concepts
27 - bidirectional_graph
28 - adjacency_graph
29 - vertex_list_graph
30 - edge_list_graph.
31
32 See the
33\external{http://www.boost.org/doc/libs/1_39_0/libs/graph/doc/table_of_contents.html,
34 Boost.Graph manual} for more details and a list of algorithms.
35
36 The vertices are Bondeds. The type of the edge_descriptors
37 is internal. You can use the get_bond() method to get the corresponding
38 Bond.
39
40 And all vertices can be assumed to have internal boost vertex indices.
41 The Boost.PropertyMap to access these can be accessed using the
42 get_vertex_index_map() function.
43
44 Some usage examples
45 \code
46 boost::isomorphism(a,b,
47 boost::isomorphism_map(BondGraph::VertexVertexPropertyMap(pk))
48 .vertex_index1_map(a.get_vertex_index_map())
49 .vertex_index2_map(b.get_vertex_index_map()));
50boost::dijkstra_shortest_paths(a, Bonded(),
51 boost::predecessor_map(BondGraph::VertexVertexPropertyMap(pk))
52 .weight_map(BondGraph::EdgeFloatPropertyMap(Bond::get_legnth_key()))
53 .distance_map(BondGraph::VertexFloatPropertyMap(FloatKey("graph distance")))
54 .vertex_index_map(a.get_vertex_index_map()));
55 \endcode
56
57 \untested{BondGraph}
58 */
59class IMPATOMEXPORT BondGraph {
60
61 mutable IntKey index_key_;
62
63 public:
64 IMP_NO_DOXYGEN(mutable Particles sc_);
65
66 //! The graph is on the leaves of the atom::Hierarchy
67 /** All the leaves will be made Bonded particles if they are not already.
68 \note The hierarchy must not have any bonds to particles not in the
69 hierarchy.
70 */
72
73 BondGraph() {}
74
75 ~BondGraph();
76
77#ifndef IMP_DOXYGEN
78
79 typedef internal::AttributeVertexPropertyMap<FloatKey, Float>
80 VertexFloatPropertyMap;
81 typedef internal::AttributeVertexPropertyMap<IntKey, Int>
82 VertexIntPropertyMap;
83 typedef internal::AttributeVertexPropertyMap<ParticleIndexKey, Bonded>
84 VertexVertexPropertyMap;
85
86 typedef internal::AttributeEdgePropertyMap<FloatKey, Float>
87 EdgeFloatPropertyMap;
88 typedef internal::AttributeEdgePropertyMap<IntKey, Int> EdgeIntPropertyMap;
89
90 VertexIntPropertyMap get_vertex_index_map() const;
91#else
92 /** @name Property maps
93 Boost.Graph makes extensive use of property maps. We define a few maps
94 which use the particle attributes to store their data. Each map is
95 constructed by passing an appropriate attribute key, to specify the
96 attribute used to store the data. Attempt to store to an attribute
97 which the particle does not already have adds the attribute to the
98 particle. More information about property maps can be found in
99\external{http://www.boost.org/doc/libs/1_39_0/libs/property_map/property_map.html,
100 the Boost.PropertyMap documentation}.
101 @{
102 */
103 //! Provide boost access to a Float attribute each vertex
105 //! Provide boost access to an Int attribute each vertex
107 //! Provide boost access to a Particle attribute each vertex
108 /** The particles in question must be Bonded particles. */
110 //! Provide boost access to a Float attribute on the edges such as length
112 //! Provide boost access to an Int attribute on each edge.
114
115 VertexIntPropertyMap get_vertex_index_map() const;
116/** @} */
117#endif
118
119#ifndef IMP_DOXYGEN
120 typedef std::pair<Bonded, Bonded> edge_descriptor;
121#endif
122
123 Bond get_bond(edge_descriptor d) const {
124 return IMP::atom::get_bond(d.first, d.second);
125 }
126
127#ifndef IMP_DOXYGEN
128 struct traversal_category : public virtual boost::adjacency_graph_tag,
129 public virtual boost::vertex_list_graph_tag,
130 public virtual boost::edge_list_graph_tag,
131 // public virtual boost::incidence_graph_tag
132 public virtual boost::bidirectional_graph_tag {};
133 typedef Bonded vertex_descriptor;
134 // typedef undirected_tag directed_category;
135 typedef int vertices_size_type;
136 typedef int edges_size_type;
137 typedef int degree_size_type;
138
139 typedef boost::transform_iterator<internal::MakeOutEdgeDescriptor,
140 vertex_descriptor::BondIterator>
141 out_edge_iterator;
142 typedef vertex_descriptor::BondedIterator adjacency_iterator;
143 typedef boost::transform_iterator<
144 internal::MakeBonded, IMP::Particles::iterator> vertex_iterator;
145 typedef boost::disallow_parallel_edge_tag edge_parallel_category;
146 typedef boost::undirected_tag directed_category;
147
148 typedef boost::transform_iterator<internal::MakeInEdgeDescriptor,
149 vertex_descriptor::BondIterator>
150 in_edge_iterator;
151
152 typedef IMP::internal::NestedIterator<internal::NestedTraits> edge_iterator;
153
154 struct graph_tag {};
155 typedef Int vertex_property_type;
156#endif
157};
158
159IMPATOM_END_NAMESPACE
160
161#include "internal/bond_graph_boost_functions.h"
162
163#endif // IMP_SWIG
164
165#endif /* IMPATOM_BOND_GRAPH_H */
Store a list of ParticleIndexes.
Decorator for helping deal with a hierarchy of molecules.
Contains decorators for a bond.
Represent a bond graph as a boost graph.
Definition bond_graph.h:59
VertexVertexPropertyMap
Provide boost access to a Particle attribute each vertex.
Definition bond_graph.h:109
EdgeFloatPropertyMap
Provide boost access to a Float attribute on the edges such as length.
Definition bond_graph.h:111
BondGraph(Hierarchy bd)
The graph is on the leaves of the atom::Hierarchy.
VertexFloatPropertyMap
Provide boost access to a Float attribute each vertex.
Definition bond_graph.h:104
VertexIntPropertyMap
Provide boost access to an Int attribute each vertex.
Definition bond_graph.h:106
EdgeIntPropertyMap
Provide boost access to an Int attribute on each edge.
Definition bond_graph.h:113
A decorator for wrapping a particle representing a molecular bond.
The standard decorator for manipulating molecular structures.
#define IMP_NO_DOXYGEN(x)
Hide something from doxygen.
Bond get_bond(Bonded a, Bonded b)
Get the bond between two particles.
Vector< Pointer< Particle > > Particles
A list of reference-counted Particle objects.
Definition base_types.h:138
Key< 1 > IntKey
The type used to identify int attributes in the Particles.
Definition base_types.h:36