Chris@16: // Copyright (C) 2009 Andrew Sutton Chris@16: Chris@16: // Use, modification and distribution is subject to the Boost Software Chris@16: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_GRAPH_LABELED_GRAPH_TRAITS_HPP Chris@16: #define BOOST_GRAPH_LABELED_GRAPH_TRAITS_HPP Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: // Extend the graph mutability traits (and metafunctions) to include options Chris@16: // for labeled graphs. Chris@16: Chris@16: // NOTE: the label_vertex tag denotes the fact that you can basically assign Chris@16: // arbitrary labels to vertices without modifying the actual graph. Chris@16: Chris@16: // TODO: We might also overlay the uniqueness/multiplicity of labels in this Chris@16: // hierarchy also. For now, we just assumed that labels are unique. Chris@16: Chris@16: struct label_vertex_tag { }; Chris@16: struct labeled_add_vertex_tag : virtual label_vertex_tag { }; Chris@16: struct labeled_add_vertex_property_tag : virtual labeled_add_vertex_tag { }; Chris@16: struct labeled_remove_vertex_tag { }; Chris@16: struct labeled_add_edge_tag : virtual label_vertex_tag { }; Chris@16: struct labeled_add_edge_property_tag : virtual labeled_add_edge_tag{ }; Chris@16: struct labeled_remove_edge_tag { }; Chris@16: Chris@16: struct labeled_mutable_vertex_graph_tag Chris@16: : virtual labeled_add_vertex_tag, virtual labeled_remove_vertex_tag Chris@16: { }; Chris@16: struct labeled_mutable_vertex_property_graph_tag Chris@16: : virtual labeled_add_vertex_property_tag, virtual labeled_remove_vertex_tag Chris@16: { }; Chris@16: struct labeled_mutable_edge_graph_tag Chris@16: : virtual labeled_add_edge_tag, virtual labeled_remove_edge_tag Chris@16: { }; Chris@16: struct labeled_mutable_edge_property_graph_tag Chris@16: : virtual labeled_add_edge_property_tag, virtual labeled_remove_edge_tag Chris@16: { }; Chris@16: Chris@16: struct labeled_graph_tag Chris@16: : virtual label_vertex_tag Chris@16: { }; Chris@16: struct labeled_mutable_graph_tag Chris@16: : virtual labeled_mutable_vertex_graph_tag Chris@16: , virtual labeled_mutable_edge_graph_tag Chris@16: { }; Chris@16: struct labeled_mutable_property_graph_tag Chris@16: : virtual labeled_mutable_vertex_property_graph_tag Chris@16: , virtual labeled_mutable_edge_property_graph_tag Chris@16: { }; Chris@16: struct labeled_add_only_property_graph_tag Chris@16: : virtual labeled_add_vertex_property_tag Chris@16: , virtual labeled_mutable_edge_property_graph_tag Chris@16: { }; Chris@16: Chris@16: // Metafunctions Chris@16: Chris@16: template Chris@16: struct graph_has_add_vertex_by_label Chris@16: : mpl::bool_< Chris@16: is_convertible< Chris@16: typename graph_mutability_traits::category, Chris@16: labeled_add_vertex_tag Chris@16: >::value Chris@16: > Chris@16: { }; Chris@16: Chris@16: template Chris@16: struct graph_has_add_vertex_by_label_with_property Chris@16: : mpl::bool_< Chris@16: is_convertible< Chris@16: typename graph_mutability_traits::category, Chris@16: labeled_add_vertex_property_tag Chris@16: >::value Chris@16: > Chris@16: { }; Chris@16: Chris@16: template Chris@16: struct graph_has_remove_vertex_by_label Chris@16: : mpl::bool_< Chris@16: is_convertible< Chris@16: typename graph_mutability_traits::category, Chris@16: labeled_remove_vertex_tag Chris@16: >::value Chris@16: > Chris@16: { }; Chris@16: Chris@16: template Chris@16: struct graph_has_add_edge_by_label Chris@16: : mpl::bool_< Chris@16: is_convertible< Chris@16: typename graph_mutability_traits::category, Chris@16: labeled_add_edge_tag Chris@16: >::value Chris@16: > Chris@16: { }; Chris@16: Chris@16: template Chris@16: struct graph_has_add_edge_by_label_with_property Chris@16: : mpl::bool_< Chris@16: is_convertible< Chris@16: typename graph_mutability_traits::category, Chris@16: labeled_add_edge_property_tag Chris@16: >::value Chris@16: > Chris@16: { }; Chris@16: Chris@16: template Chris@16: struct graph_has_remove_edge_by_label Chris@16: : mpl::bool_< Chris@16: is_convertible< Chris@16: typename graph_mutability_traits::category, Chris@16: labeled_remove_edge_tag Chris@16: >::value Chris@16: > Chris@16: { }; Chris@16: Chris@16: template Chris@16: struct is_labeled_mutable_vertex_graph Chris@16: : mpl::and_< Chris@16: graph_has_add_vertex_by_label, Chris@16: graph_has_remove_vertex_by_label Chris@16: > Chris@16: { }; Chris@16: Chris@16: template Chris@16: struct is_labeled_mutable_vertex_property_graph Chris@16: : mpl::and_< Chris@16: graph_has_add_vertex_by_label, Chris@16: graph_has_remove_vertex_by_label Chris@16: > Chris@16: { }; Chris@16: Chris@16: template Chris@16: struct is_labeled_mutable_edge_graph Chris@16: : mpl::and_< Chris@16: graph_has_add_edge_by_label, Chris@16: graph_has_remove_edge_by_label Chris@16: > Chris@16: { }; Chris@16: Chris@16: template Chris@16: struct is_labeled_mutable_edge_property_graph Chris@16: : mpl::and_< Chris@16: graph_has_add_edge_by_label, Chris@16: graph_has_remove_edge_by_label Chris@16: > Chris@16: { }; Chris@16: Chris@16: template Chris@16: struct is_labeled_mutable_graph Chris@16: : mpl::and_< Chris@16: is_labeled_mutable_vertex_graph, Chris@16: is_labeled_mutable_edge_graph Chris@16: > Chris@16: { }; Chris@16: Chris@16: template Chris@16: struct is_labeled_mutable_property_graph Chris@16: : mpl::and_< Chris@16: is_labeled_mutable_vertex_property_graph, Chris@16: is_labeled_mutable_edge_property_graph Chris@16: > Chris@16: { }; Chris@16: Chris@16: template Chris@16: struct is_labeled_add_only_property_graph Chris@16: : mpl::bool_< Chris@16: is_convertible< Chris@16: typename graph_mutability_traits::category, Chris@16: labeled_add_only_property_graph_tag Chris@16: >::value Chris@16: > Chris@16: { }; Chris@16: Chris@16: template Chris@16: struct is_labeled_graph Chris@16: : mpl::bool_< Chris@16: is_convertible< Chris@16: typename graph_mutability_traits::category, Chris@16: label_vertex_tag Chris@16: >::value Chris@16: > Chris@16: { }; Chris@16: Chris@16: template struct graph_mutability_traits; Chris@16: Chris@16: namespace graph_detail { Chris@16: // The determine mutability metafunction computes a labeled mutability tag Chris@16: // based on the mutability of the given graph type. This is used by the Chris@16: // graph_mutability_traits specialization below. Chris@16: template Chris@16: struct determine_mutability { Chris@16: typedef typename mpl::if_< Chris@16: is_add_only_property_graph, Chris@16: labeled_add_only_property_graph_tag, Chris@16: typename mpl::if_< Chris@16: is_mutable_property_graph, Chris@16: labeled_mutable_property_graph_tag, Chris@16: typename mpl::if_< Chris@16: is_mutable_graph, Chris@16: labeled_mutable_graph_tag, Chris@16: typename mpl::if_< Chris@16: is_mutable_edge_graph, Chris@16: labeled_graph_tag, Chris@16: typename graph_mutability_traits::category Chris@16: >::type Chris@16: >::type Chris@16: >::type Chris@16: >::type type; Chris@16: }; Chris@16: } // namespace graph_detail Chris@16: Chris@16: #define LABELED_GRAPH_PARAMS typename G, typename L, typename S Chris@16: #define LABELED_GRAPH labeled_graph Chris@16: Chris@16: // Specialize mutability traits for the labeled graph. Chris@16: // This specialization depends on the mutability of the underlying graph type. Chris@16: // If the underlying graph is fully mutable, this is also fully mutable. Chris@16: // Otherwise, it's different. Chris@16: template Chris@16: struct graph_mutability_traits< LABELED_GRAPH > { Chris@16: typedef typename graph_detail::determine_mutability< Chris@16: typename LABELED_GRAPH::graph_type Chris@16: >::type category; Chris@16: }; Chris@16: Chris@16: #undef LABELED_GRAPH_PARAMS Chris@16: #undef LABELED_GRAPH Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #endif