connected_components
diff --git a/doc/two_graphs_common_spanning_trees.html b/doc/two_graphs_common_spanning_trees.html
new file mode 100644
index 00000000..f06825b0
--- /dev/null
+++ b/doc/two_graphs_common_spanning_trees.html
@@ -0,0 +1,143 @@
+
+
+
+Boost Graph Library: Two-Graphs Common Spanning Trees
+
+
+
+
+
+
+
+
+The MRT algorithm, based on an academic article of Mint, Read and
+Tarjan, is an efficient algorithm for the common spanning tree problem.
+This kind of algorithm is widely used in electronics, being the basis of the
+analysis of electrical circuits. Another area of interest may be that of the
+networking.
+
+
+
+The proposed algorithm receives several arguments and works with callbacks.
+The prototypes are:
+
+
+
+// Ordered Edges List
+
+template < typename Graph, typename Order, typename Func, typename Seq >
+void two_graphs_common_spanning_trees
+ (
+ const Graph& iG,
+ Order iG_map,
+ const Graph& vG,
+ Order vG_map,
+ Func func,
+ Seq inL
+ )
+
+
+// Unordered Edges List
+
+template < typename Graph, typename Func, typename Seq >
+void two_graphs_common_spanning_trees
+ (
+ const Graph& iG,
+ const Graph& vG,
+ Func func,
+ Seq inL
+ )
+
+
+
+
+The problem of common spanning tree is easily described.
+Imagine we have two graphs that are represented as lists of edges. A common
+spanning tree is a set of indices that identifies a spanning tree for both
+the first and for the second of the two graphs. Despite it is easily accomplished
+with edge list representation for graphs, it is intuitively difficult to achieve
+with adjacency list representation. This is due to the fact that it is necessary
+to represent an edge with an absolute index.
+
+
+Note that the set of common spanning trees of the two graphs is a subset of
+the set of spanning trees of the first graph, as well as those of the second
+graph.
+
+
+Where Defined
+
+
+boost/graph/two_graphs_common_spanning_trees.hpp
+
+
Parameters
+
+const Graph& iG, const Graph& vG
+
+These are the graphs to be analyzed.
+They must comply with the concepts VertexAndEdgeListGraphConcept and IncidenceGraphConcept.
+In addition, the directed_category should be of type undirected_tag.
+
+
+Order iG_map, Order vG_map
+
+These are lists of references to edges, that define the preferred order for access to the lists of edges.
+They must comply with the concept RandomAccessContainer.
+
+
+Func func
+
+This is a callback that is invoked by the algorithm for each common spanning tree found.
+It must comply with the concept UnaryFunction with void as return value, and an object of type typeof(inL) as argument.
+
+
+Seq inL[1]
+
+This is the way in which the edges are marked as belonging to the common spanning tree.
+It must comply with the concept Mutable_RandomAccessContainer. In addition, the value_type should be of type bool.
+If the i-th edge or inL[i] is true, then it belongs to the common spanning tree, otherwise it does not belong.
+
+
+Example
+
+
+The file
+examples/two_graphs_common_spanning_trees.cpp
+contains an example of finding common spanning trees of two undirected graphs.
+
+
+Notes
+
+
+[1]
+ The presence of inL may seem senseless. The algorithm can use a vector of
+ placeholders internally generated. However, doing so has more flexibility on
+ the callback function. Moreover, being largely involved in the electronics
+ world, there are cases where some edges have to be forced in every tree (ie
+ you want to search all the trees that have the same root): With this
+ solution, the problem is easily solved.
+ Intuitively from the above, inL must be of a size equal to (V-1), where
+ V is the number of vertices of the graph.
+
+
+
+
+
+
+
+
diff --git a/doc/undirected_graph.html b/doc/undirected_graph.html
new file mode 100644
index 00000000..09a55b0c
--- /dev/null
+++ b/doc/undirected_graph.html
@@ -0,0 +1,96 @@
+
+
+
+Boost Graph Library: Undirected Graph
+
+
+
+
+
+
+
+undirected_graph<VertexProp, EdgeProp, GraphProp>
+
+
+
+
+
+The undirected_graph class template is is a simplified version
+of the BGL adjacency list. This class is provided for ease of use, but
+may not perform as well as custom-defined adjacency list classes. Instances
+of this template model the BidirectionalGraph, VertexIndexGraph, and
+EdgeIndexGraph concepts.
+
+
Example
+
+A simple example of creating an undirected_graph is available here libs/graph/example/undirected_graph.cpp
+
+
+
+
+ typedef boost::undirected_graph<> Graph;
+ Graph g;
+ boost::graph_traits::vertex_descriptor v0 = g.add_vertex();
+ boost::graph_traits::vertex_descriptor v1 = g.add_vertex();
+
+ g.add_edge(v0, v1);
+
+
+Template Parameters
+
+
+
+
+| Parameter | Description | Default |
+
+
+| VertexProp |
+A property map for the graph vertices. |
+ |
+
+
+
+| EdgeProp |
+A property map for the graph edges. |
+ |
+
+
+
+| GraphProp |
+A property map for the graph itself. |
+
+
+
+
+
+
Where Defined
+
+
+boost/graph/undirected_graph.hpp
+
+
+
+
+
+
+
+
+
diff --git a/example/Jamfile.v2 b/example/Jamfile.v2
index 62ae5c25..8a0c2c7d 100644
--- a/example/Jamfile.v2
+++ b/example/Jamfile.v2
@@ -20,6 +20,7 @@ exe bron_kerbosch_print_cliques : bron_kerbosch_print_cliques.cpp ;
exe bron_kerbosch_clique_number : bron_kerbosch_clique_number.cpp ;
exe mcgregor_subgraphs_example : mcgregor_subgraphs_example.cpp ;
exe grid_graph_example : grid_graph_example.cpp ;
+exe grid_graph_properties : grid_graph_properties.cpp ;
exe bipartite_example : bipartite_example.cpp ;
exe fr_layout : fr_layout.cpp ;
exe canonical_ordering : canonical_ordering.cpp ;
@@ -36,3 +37,7 @@ exe dfs-example : dfs-example.cpp ;
exe adjacency_list_io : adjacency_list_io.cpp ;
exe strong_components : strong_components.cpp ../build//boost_graph ;
exe strong-components : strong-components.cpp ;
+exe undirected_adjacency_list : undirected_adjacency_list.cpp ;
+exe directed_graph : directed_graph.cpp ;
+exe undirected_graph : undirected_graph.cpp ;
+exe two_graphs_common_spanning_trees : two_graphs_common_spanning_trees.cpp ;
diff --git a/example/directed_graph.cpp b/example/directed_graph.cpp
new file mode 100644
index 00000000..bb308aa5
--- /dev/null
+++ b/example/directed_graph.cpp
@@ -0,0 +1,26 @@
+//=======================================================================
+// Copyright 2012
+// Authors: David Doria
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//=======================================================================
+
+#include // A subclass to provide reasonable arguments to adjacency_list for a typical directed graph
+
+int main(int,char*[])
+{
+ // directed_graph is a subclass of adjacency_list which gives you object oriented access to functions
+ // like add_vertex and add_edge, which makes the code easier to understand. However, it hard codes many
+ // of the template parameters, so it is much less flexible.
+
+ typedef boost::directed_graph<> Graph;
+ Graph g;
+ boost::graph_traits::vertex_descriptor v0 = g.add_vertex();
+ boost::graph_traits::vertex_descriptor v1 = g.add_vertex();
+
+ g.add_edge(v0, v1);
+
+ return 0;
+}
diff --git a/example/grid_graph_properties.cpp b/example/grid_graph_properties.cpp
new file mode 100644
index 00000000..37d252a8
--- /dev/null
+++ b/example/grid_graph_properties.cpp
@@ -0,0 +1,40 @@
+//=======================================================================
+// Copyright 2012 David Doria
+// Authors: David Doria
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//=======================================================================
+
+#include
+#include
+#include
+
+int main(int argc, char* argv[])
+{
+ // A 2D grid graph
+ typedef boost::grid_graph<2> GraphType;
+
+ // Create a 5x5 graph
+ const unsigned int dimension = 5;
+ boost::array lengths = { { dimension, dimension } };
+ GraphType graph(lengths);
+
+ // Get the index map of the grid graph
+ typedef boost::property_map::const_type indexMapType;
+ indexMapType indexMap(get(boost::vertex_index, graph));
+
+ // Create a float for every node in the graph
+ boost::vector_property_map dataMap(num_vertices(graph), indexMap);
+
+ // Associate the value 2.0 with the node at position (0,1) in the grid
+ boost::graph_traits::vertex_descriptor v = { { 0, 1 } };
+ put(dataMap, v, 2.0f);
+
+ // Get the data at the node at position (0,1) in the grid
+ float retrieved = get(dataMap, v);
+ std::cout << "Retrieved value: " << retrieved << std::endl;
+
+ return 0;
+}
diff --git a/example/two_graphs_common_spanning_trees.cpp b/example/two_graphs_common_spanning_trees.cpp
new file mode 100644
index 00000000..2fa85179
--- /dev/null
+++ b/example/two_graphs_common_spanning_trees.cpp
@@ -0,0 +1,94 @@
+// Copyright (C) 2012, Michele Caini.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// Two Graphs Common Spanning Trees Algorithm
+// Based on academic article of Mint, Read and Tarjan
+// Efficient Algorithm for Common Spanning Tree Problem
+// Electron. Lett., 28 April 1983, Volume 19, Issue 9, p.346-347
+
+
+#include
+#include
+#include
+#include
+
+
+using namespace std;
+
+typedef
+boost::adjacency_list
+ <
+ boost::vecS, // OutEdgeList
+ boost::vecS, // VertexList
+ boost::undirectedS, // Directed
+ boost::no_property, // VertexProperties
+ boost::no_property, // EdgeProperties
+ boost::no_property, // GraphProperties
+ boost::listS // EdgeList
+ >
+Graph
+;
+
+typedef
+boost::graph_traits::vertex_descriptor
+vertex_descriptor;
+
+typedef
+boost::graph_traits::edge_descriptor
+edge_descriptor;
+
+typedef
+boost::graph_traits::vertex_iterator
+vertex_iterator;
+
+typedef
+boost::graph_traits::edge_iterator
+edge_iterator;
+
+
+int main(int argc, char **argv)
+{
+ Graph iG, vG;
+ vector< edge_descriptor > iG_o;
+ vector< edge_descriptor > vG_o;
+
+ iG_o.push_back(boost::add_edge(0, 1, iG).first);
+ iG_o.push_back(boost::add_edge(0, 2, iG).first);
+ iG_o.push_back(boost::add_edge(0, 3, iG).first);
+ iG_o.push_back(boost::add_edge(0, 4, iG).first);
+ iG_o.push_back(boost::add_edge(1, 2, iG).first);
+ iG_o.push_back(boost::add_edge(3, 4, iG).first);
+
+ vG_o.push_back(boost::add_edge(1, 2, vG).first);
+ vG_o.push_back(boost::add_edge(2, 0, vG).first);
+ vG_o.push_back(boost::add_edge(2, 3, vG).first);
+ vG_o.push_back(boost::add_edge(4, 3, vG).first);
+ vG_o.push_back(boost::add_edge(0, 3, vG).first);
+ vG_o.push_back(boost::add_edge(0, 4, vG).first);
+
+ vector inL(iG_o.size(), false);
+
+ std::vector< std::vector > coll;
+ boost::tree_collector<
+ std::vector< std::vector >,
+ std::vector
+ > tree_collector(coll);
+ boost::two_graphs_common_spanning_trees
+ (
+ iG,
+ iG_o,
+ vG,
+ vG_o,
+ tree_collector,
+ inL
+ );
+
+ std::vector< std::vector >::iterator it;
+ for(it = coll.begin(); it != coll.end(); ++it) {
+ // Here you can play with the trees that the algorithm has found.
+ }
+
+ return 0;
+}
diff --git a/example/undirected.cpp b/example/undirected_adjacency_list.cpp
similarity index 100%
rename from example/undirected.cpp
rename to example/undirected_adjacency_list.cpp
diff --git a/example/undirected.expected b/example/undirected_adjacency_list.expected
similarity index 100%
rename from example/undirected.expected
rename to example/undirected_adjacency_list.expected
diff --git a/example/undirected_graph.cpp b/example/undirected_graph.cpp
new file mode 100644
index 00000000..d926c7b5
--- /dev/null
+++ b/example/undirected_graph.cpp
@@ -0,0 +1,30 @@
+//=======================================================================
+// Copyright 2012
+// Authors: David Doria
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//=======================================================================
+
+#include
+#include
+
+typedef boost::undirected_graph Graph;
+
+int main(int,char*[])
+{
+ // Create a graph object
+ Graph g;
+
+ // Add vertices
+ boost::graph_traits::vertex_descriptor v0 = g.add_vertex();
+ boost::graph_traits::vertex_descriptor v1 = g.add_vertex();
+ boost::graph_traits::vertex_descriptor v2 = g.add_vertex();
+
+ // Add edges
+ g.add_edge(v0, v1);
+ g.add_edge(v1, v2);
+
+ return 0;
+}
diff --git a/include/boost/graph/adj_list_serialize.hpp b/include/boost/graph/adj_list_serialize.hpp
index c1ff4111..01db5028 100644
--- a/include/boost/graph/adj_list_serialize.hpp
+++ b/include/boost/graph/adj_list_serialize.hpp
@@ -61,6 +61,8 @@ inline void save(
ar << serialization::make_nvp("v" , indices[target(e,graph)]);
ar << serialization::make_nvp("edge_property", get(edge_all_t(), graph, e) );
}
+
+ ar << serialization::make_nvp("graph_property", get_property(graph, graph_all_t()) );
}
@@ -95,6 +97,7 @@ inline void load(
boost::tie(e,inserted) = add_edge(verts[u], verts[v], graph);
ar >> serialization::make_nvp("edge_property", get(edge_all_t(), graph, e) );
}
+ ar >> serialization::make_nvp("graph_property", get_property(graph, graph_all_t()) );
}
template
diff --git a/include/boost/graph/adjacency_list.hpp b/include/boost/graph/adjacency_list.hpp
index a260a0f1..21b7500d 100644
--- a/include/boost/graph/adjacency_list.hpp
+++ b/include/boost/graph/adjacency_list.hpp
@@ -51,11 +51,6 @@ namespace boost {
// adjacency_list, and the container_gen traits class which is used
// to map the selectors to the container type used to implement the
// graph.
- //
- // The main container_gen traits class uses partial specialization,
- // so we also include a workaround.
-
-#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#if !defined BOOST_NO_SLIST
struct slistS {};
@@ -130,93 +125,6 @@ namespace boost {
typedef boost::unordered_multiset type;
};
-#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
-
-#if !defined BOOST_NO_SLIST
- struct slistS {
- template
- struct bind_ { typedef BOOST_STD_EXTENSION_NAMESPACE::slist type; };
- };
-#endif
-
- struct vecS {
- template
- struct bind_ { typedef std::vector type; };
- };
-
- struct listS {
- template
- struct bind_ { typedef std::list type; };
- };
-
- struct setS {
- template
- struct bind_ { typedef std::set > type; };
- };
-
-
- struct mapS {
- template
- struct bind_ { typedef std::set > type; };
- };
-
- struct multisetS {
- template
- struct bind_ { typedef std::multiset > type; };
- };
-
- struct multimapS {
- template
- struct bind_ { typedef std::multiset > type; };
- };
-
- struct hash_setS {
- template
- struct bind_ { typedef boost::unordered_set type; };
- };
-
- struct hash_mapS {
- template
- struct bind_ { typedef boost::unordered_set type; };
- };
-
- struct hash_multisetS {
- template
- struct bind_ { typedef boost::unordered_multiset type; };
- };
-
- struct hash_multimapS {
- template
- struct bind_ { typedef boost::unordered_multiset type; };
- };
-
- template struct container_selector {
- typedef vecS type;
- };
-
-#define BOOST_CONTAINER_SELECTOR(NAME) \
- template <> struct container_selector { \
- typedef NAME type; \
- }
-
- BOOST_CONTAINER_SELECTOR(vecS);
- BOOST_CONTAINER_SELECTOR(listS);
- BOOST_CONTAINER_SELECTOR(mapS);
- BOOST_CONTAINER_SELECTOR(setS);
- BOOST_CONTAINER_SELECTOR(multisetS);
- BOOST_CONTAINER_SELECTOR(hash_mapS);
-#if !defined BOOST_NO_SLIST
- BOOST_CONTAINER_SELECTOR(slistS);
-#endif
-
- template
- struct container_gen {
- typedef typename container_selector::type Select;
- typedef typename Select:: template bind_::type type;
- };
-
-#endif // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
-
template
struct parallel_edge_traits { };
@@ -354,13 +262,7 @@ namespace boost {
adjacency_list,
VertexListS, OutEdgeListS, DirectedS,
-#if !defined(BOOST_GRAPH_NO_BUNDLED_PROPERTIES)
- typename detail::retag_property_list::type,
- typename detail::retag_property_list::type,
-#else
VertexProperty, EdgeProperty,
-#endif
GraphProperty, EdgeListS>::type,
// Support for named vertices
public graph::maybe_named_graph<
@@ -371,25 +273,14 @@ namespace boost {
VertexProperty>
{
public:
-#if !defined(BOOST_GRAPH_NO_BUNDLED_PROPERTIES)
- typedef typename graph_detail::graph_prop::property graph_property_type;
- typedef typename graph_detail::graph_prop::bundle graph_bundled;
-
- typedef typename graph_detail::vertex_prop::property vertex_property_type;
- typedef typename graph_detail::vertex_prop::bundle vertex_bundled;
-
- typedef typename graph_detail::edge_prop::property edge_property_type;
- typedef typename graph_detail::edge_prop::bundle edge_bundled;
-#else
typedef GraphProperty graph_property_type;
- typedef no_graph_bundle graph_bundled;
+ typedef typename lookup_one_property::type graph_bundled;
typedef VertexProperty vertex_property_type;
- typedef no_vertex_bundle vertex_bundled;
+ typedef typename lookup_one_property::type vertex_bundled;
typedef EdgeProperty edge_property_type;
- typedef no_edge_bundle edge_bundled;
-#endif
+ typedef typename lookup_one_property::type edge_bundled;
private:
typedef adjacency_list self;
@@ -545,58 +436,6 @@ namespace boost {
return e.m_target;
}
- // Support for bundled properties
-#ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
- template
- inline
- typename property_map, T Bundle::*>::type
- get(T Bundle::* p, adjacency_list& g)
- {
- typedef typename property_map, T Bundle::*>::type
- result_type;
- return result_type(&g, p);
- }
-
- template
- inline
- typename property_map, T Bundle::*>::const_type
- get(T Bundle::* p, adjacency_list const & g)
- {
- typedef typename property_map, T Bundle::*>::const_type
- result_type;
- return result_type(&g, p);
- }
-
- template
- inline T
- get(T Bundle::* p, adjacency_list const & g, const Key& key)
- {
- return get(get(p, g), key);
- }
-
- template
- inline void
- put(T Bundle::* p, adjacency_list& g, const Key& key, const T& value)
- {
- put(get(p, g), key, value);
- }
-
-#endif
-
// Mutability Traits
template
struct graph_mutability_traits {
diff --git a/include/boost/graph/adjacency_list_io.hpp b/include/boost/graph/adjacency_list_io.hpp
index 547c0290..aaba8a43 100644
--- a/include/boost/graph/adjacency_list_io.hpp
+++ b/include/boost/graph/adjacency_list_io.hpp
@@ -40,7 +40,7 @@ namespace boost {
template
std::istream& operator >> ( std::istream& in, property& p )
{
- in >> p.m_value >> *(static_cast(&p)); // houpla !!
+ in >> p.m_value >> p.m_base; // houpla !!
return in;
}
@@ -65,7 +65,7 @@ template
void get
( property& p, const V& v, Stag s )
{
- get( *(static_cast(&p)),v,s );
+ get( p.m_base,v,s );
}
template
@@ -82,7 +82,7 @@ void getSubset
( property& p, const property& s )
{
get( p, s.m_value, Stag() );
- getSubset( p, Snext(s) );
+ getSubset( p, s.m_base );
}
template
#include
#include
+#include
#include
#include
#include
@@ -29,7 +30,10 @@
#include
#include
#include
-#include
+#include
+#include
+#include
+#include
namespace boost {
@@ -484,25 +488,14 @@ namespace boost {
BOOST_STATIC_ASSERT(!(is_same::value));
#endif
-#if !defined(BOOST_GRAPH_NO_BUNDLED_PROPERTIES)
- typedef typename graph_detail::graph_prop::property graph_property_type;
- typedef typename graph_detail::graph_prop::bundle graph_bundled;
-
- typedef typename graph_detail::vertex_prop::property vertex_property_type;
- typedef typename graph_detail::vertex_prop::bundle vertex_bundled;
-
- typedef typename graph_detail::edge_prop::property edge_property_type;
- typedef typename graph_detail::edge_prop::bundle edge_bundled;
-#else
typedef GraphProperty graph_property_type;
- typedef no_graph_bundle graph_bundled;
+ typedef typename lookup_one_property::type graph_bundled;
typedef VertexProperty vertex_property_type;
- typedef no_vertex_bundle vertex_bundled;
+ typedef typename lookup_one_property::type vertex_bundled;
typedef EdgeProperty edge_property_type;
- typedef no_edge_bundle edge_bundled;
-#endif
+ typedef typename lookup_one_property::type edge_bundled;
public: // should be private
typedef typename mpl::if_::type,
@@ -640,16 +633,16 @@ namespace boost {
#ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
// Directly access a vertex or edge bundle
vertex_bundled& operator[](vertex_descriptor v)
- { return get(vertex_bundle, *this)[v]; }
+ { return get(vertex_bundle, *this, v); }
const vertex_bundled& operator[](vertex_descriptor v) const
- { return get(vertex_bundle, *this)[v]; }
+ { return get(vertex_bundle, *this, v); }
edge_bundled& operator[](edge_descriptor e)
- { return get(edge_bundle, *this)[e]; }
+ { return get(edge_bundle, *this, e); }
const edge_bundled& operator[](edge_descriptor e) const
- { return get(edge_bundle, *this)[e]; }
+ { return get(edge_bundle, *this, e); }
graph_bundled& operator[](graph_bundle_t)
{ return get_property(*this); }
@@ -1035,256 +1028,194 @@ namespace boost {
//=========================================================================
// Functions required by the PropertyGraph concept
+ template
+ struct adj_mat_pm_helper;
+
+ template
+ struct adj_mat_pm_helper {
+ typedef typename graph_traits >::vertex_descriptor arg_type;
+ typedef typed_identity_property_map vi_map_type;
+ typedef iterator_property_map::iterator, vi_map_type> all_map_type;
+ typedef iterator_property_map::const_iterator, vi_map_type> all_map_const_type;
+ typedef transform_value_property_map<
+ detail::lookup_one_property_f,
+ all_map_type>
+ type;
+ typedef transform_value_property_map<
+ detail::lookup_one_property_f,
+ all_map_const_type>
+ const_type;
+ typedef typename property_traits::reference single_nonconst_type;
+ typedef typename property_traits::reference single_const_type;
+
+ static type get_nonconst(adjacency_matrix& g, Prop prop) {
+ return type(prop, all_map_type(g.m_vertex_properties.begin(), vi_map_type()));
+ }
+
+ static const_type get_const(const adjacency_matrix& g, Prop prop) {
+ return const_type(prop, all_map_const_type(g.m_vertex_properties.begin(), vi_map_type()));
+ }
+
+ static single_nonconst_type get_nonconst_one(adjacency_matrix& g, Prop prop, arg_type v) {
+ return lookup_one_property::lookup(g.m_vertex_properties[v], prop);
+ }
+
+ static single_const_type get_const_one(const adjacency_matrix& g, Prop prop, arg_type v) {
+ return lookup_one_property::lookup(g.m_vertex_properties[v], prop);
+ }
+ };
+
+ template
+ struct adj_mat_pm_helper {
+ typedef typename graph_traits >::edge_descriptor edge_descriptor;
+
+ template
+ struct lookup_property_from_edge {
+ Tag tag;
+ lookup_property_from_edge(Tag tag): tag(tag) {}
+ typedef typename boost::mpl::if_::type ep_type_nonref;
+ typedef ep_type_nonref& ep_type;
+ typedef typename lookup_one_property::type& result_type;
+ result_type operator()(edge_descriptor e) const {
+ return lookup_one_property::lookup(*static_cast(e.get_property()), tag);
+ }
+ };
+
+ typedef function_property_map<
+ lookup_property_from_edge,
+ typename graph_traits >::edge_descriptor> type;
+ typedef function_property_map<
+ lookup_property_from_edge,
+ typename graph_traits >::edge_descriptor> const_type;
+ typedef edge_descriptor arg_type;
+ typedef typename lookup_property_from_edge::result_type single_nonconst_type;
+ typedef typename lookup_property_from_edge::result_type single_const_type;
+
+ static type get_nonconst(adjacency_matrix& g, Tag tag) {
+ return type(tag);
+ }
+
+ static const_type get_const(const adjacency_matrix& g, Tag tag) {
+ return const_type(tag);
+ }
+
+ static single_nonconst_type get_nonconst_one(adjacency_matrix& g, Tag tag, edge_descriptor e) {
+ return lookup_one_property::lookup(*static_cast(e.get_property()), tag);
+ }
+
+ static single_const_type get_const_one(const adjacency_matrix& g, Tag tag, edge_descriptor e) {
+ return lookup_one_property::lookup(*static_cast(e.get_property()), tag);
+ }
+ };
+
+ template
+ struct property_map, Tag>
+ : adj_mat_pm_helper, Tag>::type> {};
+
+ template
+ typename property_map, Tag>::type
+ get(Tag tag, adjacency_matrix& g) {
+ return property_map, Tag>::get_nonconst(g, tag);
+ }
+
+ template
+ typename property_map, Tag>::const_type
+ get(Tag tag, const adjacency_matrix& g) {
+ return property_map, Tag>::get_const(g, tag);
+ }
+
+ template
+ typename property_map, Tag>::single_nonconst_type
+ get(Tag tag, adjacency_matrix& g, typename property_map, Tag>::arg_type a) {
+ return property_map, Tag>::get_nonconst_one(g, tag, a);
+ }
+
+ template
+ typename property_map, Tag>::single_const_type
+ get(Tag tag, const adjacency_matrix& g, typename property_map, Tag>::arg_type a) {
+ return property_map, Tag>::get_const_one(g, tag, a);
+ }
+
+ template
+ void
+ put(Tag tag,
+ adjacency_matrix& g,
+ typename property_map, Tag>::arg_type a,
+ typename property_map, Tag>::single_const_type val) {
+ property_map, Tag>::get_nonconst_one(g, tag, a) = val;
+ }
+
// O(1)
template
inline void
- set_property(adjacency_matrix& g, Tag, const Value& value)
+ set_property(adjacency_matrix& g, Tag tag, const Value& value)
{
- get_property_value(g.m_property, Tag()) = value;
+ get_property_value(g.m_property, tag) = value;
}
template
inline typename graph_property, Tag>::type&
- get_property(adjacency_matrix& g, Tag)
+ get_property(adjacency_matrix& g, Tag tag)
{
- return get_property_value(g.m_property, Tag());
+ return get_property_value(g.m_property, tag);
}
template
inline const typename graph_property, Tag>::type&
- get_property(const adjacency_matrix& g, Tag)
+ get_property(const adjacency_matrix& g, Tag tag)
{
- return get_property_value(g.m_property, Tag());
+ return get_property_value(g.m_property, tag);
}
//=========================================================================
// Vertex Property Map
- template
- class adj_matrix_vertex_property_map
- : public put_get_helper >
- {
- public:
- typedef T value_type;
- typedef R reference;
- typedef Vertex key_type;
- typedef boost::lvalue_property_map_tag category;
- adj_matrix_vertex_property_map() { }
- adj_matrix_vertex_property_map(GraphPtr g) : m_g(g) { }
- inline reference operator[](key_type v) const {
- return get_property_value(m_g->m_vertex_properties[v], Tag());
- }
- GraphPtr m_g;
+ template
+ struct property_map, vertex_index_t> {
+ typedef typename adjacency_matrix::vertex_descriptor Vertex;
+ typedef typed_identity_property_map type;
+ typedef type const_type;
};
- template
- struct adj_matrix_vertex_id_map
- : public boost::put_get_helper >
- {
- typedef Vertex value_type;
- typedef Vertex reference;
- typedef Vertex key_type;
- typedef boost::readable_property_map_tag category;
- adj_matrix_vertex_id_map() { }
- template
- inline adj_matrix_vertex_id_map(const Graph&) { }
- inline value_type operator[](key_type v) const { return v; }
- };
-
- namespace detail {
-
- struct adj_matrix_any_vertex_pa {
- template
- struct bind_ {
- typedef typename property_value::type Value;
- typedef typename boost::graph_traits::vertex_descriptor Vertex;
-
- typedef adj_matrix_vertex_property_map type;
- typedef adj_matrix_vertex_property_map const_type;
- };
- };
- struct adj_matrix_id_vertex_pa {
- template
- struct bind_ {
- typedef typename Graph::vertex_descriptor Vertex;
- typedef adj_matrix_vertex_id_map type;
- typedef adj_matrix_vertex_id_map const_type;
- };
- };
-
- template
- struct adj_matrix_choose_vertex_pa_helper {
- typedef adj_matrix_any_vertex_pa type;
- };
- template <>
- struct adj_matrix_choose_vertex_pa_helper {
- typedef adj_matrix_id_vertex_pa type;
- };
-
- template
- struct adj_matrix_choose_vertex_pa {
- typedef typename adj_matrix_choose_vertex_pa_helper::type Helper;
- typedef typename Helper::template bind_ Bind;
- typedef typename Bind::type type;
- typedef typename Bind::const_type const_type;
- };
-
- struct adj_matrix_vertex_property_selector {
- template
- struct bind_ {
- typedef adj_matrix_choose_vertex_pa Choice;
- typedef typename Choice::type type;
- typedef typename Choice::const_type const_type;
- };
- };
-
- } // namespace detail
-
- template <>
- struct vertex_property_selector {
- typedef detail::adj_matrix_vertex_property_selector type;
- };
-
- //=========================================================================
- // Edge Property Map
-
-
- template
- class adj_matrix_edge_property_map
- : public put_get_helper >
- {
- public:
- typedef T value_type;
- typedef R reference;
- typedef detail::matrix_edge_desc_impl key_type;
- typedef boost::lvalue_property_map_tag category;
- inline reference operator[](key_type e) const {
- Property& p = *(Property*)e.get_property();
- return get_property_value(p, Tag());
- }
- };
- struct adj_matrix_edge_property_selector {
- template
- struct bind_ {
- typedef typename property_value::type T;
- typedef typename Graph::vertex_descriptor Vertex;
- typedef adj_matrix_edge_property_map type;
- typedef adj_matrix_edge_property_map const_type;
- };
- };
- template <>
- struct edge_property_selector {
- typedef adj_matrix_edge_property_selector type;
- };
-
- //=========================================================================
- // Functions required by PropertyGraph
-
- namespace detail {
-
- template
- typename boost::property_map,
- Property>::type
- get_dispatch(adjacency_matrix& g, Property,
- vertex_property_tag)
- {
- typedef adjacency_matrix Graph;
- typedef typename boost::property_map,
- Property>::type PA;
- return PA(&g);
- }
- template
- typename boost::property_map,
- Property>::type
- get_dispatch(adjacency_matrix&, Property,
- edge_property_tag)
- {
- typedef typename boost::property_map,
- Property>::type PA;
- return PA();
- }
- template
- typename boost::property_map,
- Property>::const_type
- get_dispatch(const adjacency_matrix& g, Property,
- vertex_property_tag)
- {
- typedef adjacency_matrix Graph;
- typedef typename boost::property_map,
- Property>::const_type PA;
- return PA(&g);
- }
- template
- typename boost::property_map,
- Property>::const_type
- get_dispatch(const adjacency_matrix&, Property,
- edge_property_tag)
- {
- typedef typename boost::property_map,
- Property>::const_type PA;
- return PA();
- }
-
- } // namespace detail
-
- template
- inline
- typename property_map, Property>::type
- get(Property p, adjacency_matrix& g)
- {
- typedef typename property_kind::type Kind;
- return detail::get_dispatch(g, p, Kind());
+ template
+ typename property_map