diff --git a/include/boost/graph/adjacency_matrix.hpp b/include/boost/graph/adjacency_matrix.hpp index a089e1cb..2a6ae889 100644 --- a/include/boost/graph/adjacency_matrix.hpp +++ b/include/boost/graph/adjacency_matrix.hpp @@ -433,7 +433,8 @@ struct adj_matrix_traversal_tag : public virtual adjacency_matrix_tag, public virtual vertex_list_graph_tag, public virtual incidence_graph_tag, public virtual adjacency_graph_tag, - public virtual edge_list_graph_tag + public virtual edge_list_graph_tag, + public virtual bidirectional_graph_tag { }; @@ -826,6 +827,26 @@ typename adjacency_matrix< D, VP, EP, GP, A >::degree_size_type in_degree( return n; } +// degree +template < typename VP, typename EP, typename GP, typename A > +typename adjacency_matrix< directedS, VP, EP, GP, A >::degree_size_type +degree( + typename adjacency_matrix< directedS, VP, EP, GP, A >::vertex_descriptor u, + const adjacency_matrix< directedS, VP, EP, GP, A >& g) +{ + return in_degree(u, g) + out_degree(u, g); +} + +template < typename VP, typename EP, typename GP, typename A > +typename adjacency_matrix< undirectedS, VP, EP, GP, A >::degree_size_type +degree( + typename adjacency_matrix< undirectedS, VP, EP, GP, A >::vertex_descriptor + u, + const adjacency_matrix< undirectedS, VP, EP, GP, A >& g) +{ + return out_degree(u, g); +} + //========================================================================= // Functions required by the AdjacencyGraph concept diff --git a/test/adj_matrix_cc.cpp b/test/adj_matrix_cc.cpp index 9457a70c..68d024ca 100644 --- a/test/adj_matrix_cc.cpp +++ b/test/adj_matrix_cc.cpp @@ -21,6 +21,7 @@ int main(int, char*[]) BOOST_CONCEPT_ASSERT((EdgeListGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((IncidenceGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((AdjacencyGraphConcept< Graph >)); + BOOST_CONCEPT_ASSERT((BidirectionalGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((MutableGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((AdjacencyMatrixConcept< Graph >)); } @@ -30,6 +31,7 @@ int main(int, char*[]) BOOST_CONCEPT_ASSERT((EdgeListGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((IncidenceGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((AdjacencyGraphConcept< Graph >)); + BOOST_CONCEPT_ASSERT((BidirectionalGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((MutableGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((AdjacencyMatrixConcept< Graph >)); } @@ -44,6 +46,7 @@ int main(int, char*[]) BOOST_CONCEPT_ASSERT((EdgeListGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((IncidenceGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((AdjacencyGraphConcept< Graph >)); + BOOST_CONCEPT_ASSERT((BidirectionalGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((AdjacencyMatrixConcept< Graph >)); BOOST_CONCEPT_ASSERT((VertexMutablePropertyGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((EdgeMutablePropertyGraphConcept< Graph >)); @@ -64,6 +67,7 @@ int main(int, char*[]) BOOST_CONCEPT_ASSERT((EdgeListGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((IncidenceGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((AdjacencyGraphConcept< Graph >)); + BOOST_CONCEPT_ASSERT((BidirectionalGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((AdjacencyMatrixConcept< Graph >)); BOOST_CONCEPT_ASSERT((VertexMutablePropertyGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((EdgeMutablePropertyGraphConcept< Graph >)); diff --git a/test/reverse_graph_cc.cpp b/test/reverse_graph_cc.cpp index 7965f25c..a4e5c56c 100644 --- a/test/reverse_graph_cc.cpp +++ b/test/reverse_graph_cc.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -59,5 +60,26 @@ int main(int, char*[]) get_property(gr, graph_name_t()); set_property(gr, graph_name_t(), "foo"); } + // Check matrix + { + typedef adjacency_matrix< directedS, + property< vertex_color_t, int >, property< edge_weight_t, int >, + property< graph_name_t, std::string > > + AdjMatrix; + typedef reverse_graph< AdjMatrix > Graph; + BOOST_CONCEPT_ASSERT((VertexListGraphConcept< Graph >)); + BOOST_CONCEPT_ASSERT((BidirectionalGraphConcept< Graph >)); + typedef graph_traits< Graph >::vertex_descriptor Vertex; + typedef graph_traits< Graph >::edge_descriptor Edge; + BOOST_CONCEPT_ASSERT( + (ReadablePropertyGraphConcept< Graph, Vertex, vertex_color_t >)); + BOOST_CONCEPT_ASSERT( + (ReadablePropertyGraphConcept< Graph, Edge, edge_weight_t >)); + BOOST_CONCEPT_ASSERT( + (ReadablePropertyGraphConcept< Graph, Edge, edge_underlying_t >)); + AdjMatrix g(42); + Graph gr(g); + get_property(gr, graph_name_t()); + } return 0; } diff --git a/test/test_graphs.cpp b/test/test_graphs.cpp index 81c489bb..577d9fff 100644 --- a/test/test_graphs.cpp +++ b/test/test_graphs.cpp @@ -132,6 +132,8 @@ int main() Graph; BOOST_META_ASSERT(is_directed_graph< Graph >); BOOST_META_ASSERT(!is_multigraph< Graph >); + BOOST_META_ASSERT(is_bidirectional_graph< Graph >); + BOOST_META_ASSERT(is_directed_bidirectional_graph< Graph >); BOOST_META_ASSERT(has_vertex_property< Graph >); BOOST_META_ASSERT(has_bundled_vertex_property< Graph >); BOOST_META_ASSERT(has_edge_property< Graph >); @@ -145,6 +147,8 @@ int main() typedef adjacency_matrix< directedS, VertexBundle, EdgeBundle > Graph; BOOST_META_ASSERT(is_directed_graph< Graph >); BOOST_META_ASSERT(!is_multigraph< Graph >); + BOOST_META_ASSERT(is_bidirectional_graph< Graph >); + BOOST_META_ASSERT(is_directed_bidirectional_graph< Graph >); BOOST_META_ASSERT(has_vertex_property< Graph >); BOOST_META_ASSERT(has_bundled_vertex_property< Graph >); BOOST_META_ASSERT(has_edge_property< Graph >);