9 #ifndef IMPBASE_GRAPH_MACROS_H
10 #define IMPBASE_GRAPH_MACROS_H
11 #include <IMP/base/base_config.h>
12 #include <boost/graph/adjacency_list.hpp>
14 #include "internal/graph_utility.h"
16 #include <boost/version.hpp>
18 #if defined(IMP_DOXYGEN)
29 #define IMP_GRAPH(Name, directionality, VertexData, EdgeData, ShowVertex) \
31 typedef boost::graph Name; \
32 typedef Name::VertexNameMap Name##ConstVertexName; \
33 typedef Name::EdgeNameMap Name##ConstEdgeName; \
34 typedef boost::graph_traits<Name> Name##Traits; \
35 typedef Name::vertex_descriptor Name##Vertex; \
36 typedef Name::edge_descriptor Name##Edge; \
37 class Name##VertexIndex {}; \
38 inline void show_as_graphviz(const Name& name, base::TextOutput out); \
39 Name##VertexIndex get_vertex_index(const Name& g)
42 #if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && \
43 BOOST_VERSION <= 104800
44 #define IMP_GRAPH(Name, directionality, VertexData, EdgeData, ShowVertex) \
46 inline void show_as_graphviz(const Name& name, base::TextOutput out); \
47 class Name##VertexIndex {}
50 #define IMP_GRAPH(Name, directionality, VertexData, EdgeData, ShowVertex) \
52 class Name##VertexIndex {}; \
53 inline void show_as_graphviz(const Name& name, base::TextOutput out); \
54 inline Name##VertexIndex get_vertex_index(const Name& g)
57 #else // swig and doxygen
62 #if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 7 && \
63 BOOST_VERSION == 104800
64 #define IMP_GRAPH_MAP_TYPE std::map
66 #define IMP_GRAPH_MAP_TYPE base::map
69 #define IMP_GRAPH(Name, directionality, VertexData, EdgeData, ShowVertex) \
70 typedef boost::adjacency_list< \
71 boost::vecS, boost::vecS, boost::directionality##S, \
72 boost::property<boost::vertex_name_t, VertexData>, \
73 boost::property<boost::edge_name_t, EdgeData> > Name; \
74 typedef boost::property_map<Name, boost::vertex_name_t>::const_type \
75 Name##ConstVertexName; \
76 typedef boost::property_map<Name, boost::edge_name_t>::const_type \
77 Name##ConstEdgeName; \
78 typedef boost::graph_traits<Name> Name##Traits; \
79 typedef Name##Traits::vertex_descriptor Name##Vertex; \
80 typedef Name##Traits::edge_descriptor Name##Edge; \
81 typedef IMP_GRAPH_MAP_TYPE<VertexData, Name##Vertex> Name##VertexIndex; \
82 inline Name##VertexIndex get_vertex_index(const Name& g) { \
83 return IMP::base::internal::get_graph_vertex_index< \
84 Name, VertexData, Name##Vertex, Name##Traits>(g); \
86 struct Show##Name##Vertex { \
87 void operator()(VertexData vertex, base::TextOutput out) const { \
91 inline void show_as_graphviz(const Name& graph, base::TextOutput out) { \
92 IMP::base::internal::show_as_graphviz(graph, Show##Name##Vertex(), out); \
94 typedef boost::property_map<Name, boost::edge_name_t>::type Name##EdgeName; \
95 typedef boost::property_map<Name, boost::vertex_name_t>::type Name##VertexName
96 #endif // swig and doxygen
98 #if defined(IMP_DOXYGEN) || defined(SWIG)
102 #define IMP_WEIGHTED_GRAPH(Name, directionality, VertexData, ShowVertex) \
104 IMP_GRAPH(Name, directionality, VertexData, double, ShowVertex)
107 #define IMP_WEIGHTED_GRAPH(Name, directionality, VertexData, ShowVertex) \
110 #define IMP_WEIGHTED_GRAPH(Name, directionality, VertexData, ShowVertex) \
111 typedef boost::adjacency_list< \
112 boost::vecS, boost::vecS, boost::directionality##S, \
113 boost::property<boost::vertex_name_t, VertexData>, \
114 boost::property<boost::edge_weight_t, double> > Name; \
115 typedef boost::property_map<Name, boost::vertex_name_t>::const_type \
116 Name##ConstVertexName; \
117 typedef boost::property_map<Name, boost::edge_weight_t>::const_type \
118 Name##ConstEdgeWeight; \
119 typedef boost::graph_traits<Name> Name##Traits; \
120 typedef Name##Traits::vertex_descriptor Name##Vertex; \
121 typedef Name##Traits::edge_descriptor Name##Edge; \
122 typedef base::map<VertexData, Name##Vertex> Name##VertexIndex; \
123 inline Name##VertexIndex get_vertex_index(const Name& g) { \
124 return IMP::base::internal::get_graph_vertex_index< \
125 Name, VertexData, Name##Vertex, Name##Traits>(g); \
127 struct Show##Name##Vertex { \
128 void operator()(VertexData vertex, base::TextOutput out) const { \
132 inline void show_as_graphviz(const Name& graph, base::TextOutput out) { \
133 IMP::base::internal::show_as_graphviz(graph, Show##Name##Vertex(), out); \
135 typedef boost::property_map<Name, boost::edge_weight_t>::type \
137 typedef boost::property_map<Name, boost::vertex_name_t>::type Name##VertexName
Handling of file input/output.
Declare an efficient stl-compatible map.