Boost logo

Boost-Commit :

From: gordon_at_[hidden]
Date: 2008-08-25 14:12:12


Author: gordon.woodhull
Date: 2008-08-25 14:12:11 EDT (Mon, 25 Aug 2008)
New Revision: 48385
URL: http://svn.boost.org/trac/boost/changeset/48385

Log:
better names for things
Added:
   sandbox/metagraph/boost/metagraph/fusion_graph/fusion_graph.hpp
      - copied, changed from r48383, /sandbox/metagraph/boost/metagraph/fusion_graph/fusion_graph.h
   sandbox/metagraph/boost/metagraph/mpl_graph/depth_first_search.hpp
      - copied, changed from r48383, /sandbox/metagraph/boost/metagraph/mpl_graph/dfs.hpp
   sandbox/metagraph/boost/metagraph/mpl_graph/mpl_graph.hpp
      - copied unchanged from r48383, /sandbox/metagraph/boost/metagraph/mpl_graph/mpl_graph.h
   sandbox/metagraph/libs/metagraph/example/depth_first_search.cpp
      - copied unchanged from r48384, /sandbox/metagraph/libs/metagraph/example/dfs.cpp
Removed:
   sandbox/metagraph/boost/metagraph/fusion_graph/fusion_graph.h
   sandbox/metagraph/boost/metagraph/mpl_graph/dfs.hpp
   sandbox/metagraph/boost/metagraph/mpl_graph/mpl_graph.h
   sandbox/metagraph/libs/metagraph/example/dfs.cpp
Text files modified:
   sandbox/metagraph/boost/metagraph/fusion_graph/fusion_graph.hpp | 2 +-
   sandbox/metagraph/boost/metagraph/mpl_graph/depth_first_search.hpp | 2 +-
   sandbox/metagraph/libs/metagraph/example/fusion_graph.cpp | 2 +-
   sandbox/metagraph/libs/metagraph/example/mpl_graph.cpp | 2 +-
   4 files changed, 4 insertions(+), 4 deletions(-)

Deleted: sandbox/metagraph/boost/metagraph/fusion_graph/fusion_graph.h
==============================================================================
--- sandbox/metagraph/boost/metagraph/fusion_graph/fusion_graph.h 2008-08-25 14:12:11 EDT (Mon, 25 Aug 2008)
+++ (empty file)
@@ -1,106 +0,0 @@
-// fusion_graph - a heterogeneous typed graph data structure
-
-// (c) 2008 Gordon Woodhull
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSEmpl::_1_0.txt or copy at
-// http://www.boost.org/LICENSEmpl::_1_0.txt)
-
-#include <boost/metagraph/mpl_graph/mpl_graph.h>
-
-#include <boost/fusion/include/map.hpp>
-#include <boost/fusion/include/pair.hpp>
-#include <boost/fusion/include/insert.hpp>
-#include <boost/fusion/include/as_map.hpp>
-#include <boost/fusion/include/mpl.hpp>
-#include <boost/fusion/include/at_key.hpp>
-
-#include <list>
-
-
-namespace boost {
-namespace metagraph {
-namespace fusion_graph {
-
-// input: an mpl_graph of vertex-types and edge-relations annotated with
-// instructions on the web of types-that-refer-to-each-other to generate
-
-// note a fusion_graph's nodes and edges are all different types, although
-// there may be many instances of a particular type. as a particular example,
-// one might specify a minimal graph adt as a fusion_graph of three types G, N, and E
-// G -> N <-> E "A graph contains containers of pointers to nodes, which contain
-// containers of pointers to edges, which contain pointers to nodes."
-
-// output: a type generator for the requested interlinked types - look up
-// the implementation using tags of input graph with fig::vertex_impl<vertex_tag>::type
-// or fig::edge_impl<edge_tag>::type. note edge data is all stored in source nodes
-// and accessed using fig::access_edge<edge_tag>(vertex)
-
-// this should all be abstracted better (another level is planned), but here's a start
-template<typename InputGraph>
-struct make_fusion_graph {
- struct type {
- template<typename VertexTag> struct vertex_impl;
- template<typename EdgeTag>
- struct edge_impl {
- struct type {
- typedef typename vertex_impl<typename mpl_graph::target<EdgeTag,InputGraph>::type>::type target_type;
- typedef typename EdgeTag::template link_container<target_type>::type link_type;
-
- link_type link;
- typename EdgeTag::data_type data;
- };
- };
-
- template<typename VertexTag>
- struct vertex_impl {
- struct type {
- typedef typename mpl::transform<typename mpl_graph::out_edges<VertexTag,InputGraph>::type,
- fusion::pair<mpl::_1,
- edge_impl<mpl::_1> >
- >::type tag_n_impl_sequence;
- typedef typename VertexTag::template edges_container<tag_n_impl_sequence>::type
- edges_type;
- edges_type edges;
- typename VertexTag::data_type data;
- };
- };
- };
-};
-
-// some vertex and edge data specification classes
-
-// tells fusion_graph to use a fusion::map to keep track of edges in a vertex
-template<typename Data>
-struct mapper_vertex {
- typedef Data data_type;
- template<typename EdgeTagImplVec>
- struct edges_container :
- boost::fusion::result_of::as_map<EdgeTagImplVec>
- {};
-};
-
-// tells fusion_graph to use a pointer to store zero/one link in edge
-template<typename Data>
-struct ptr_edge {
- typedef Data data_type;
- template<typename VertexImpl>
- struct link_container {
- typedef VertexImpl* type;
- };
-};
-// tells fusion_graph to use a list to store zero or more links in edge
-template<typename Data>
-struct ptr_list_edge {
- typedef Data data_type;
- template<typename VertexImpl>
- struct link_container {
- typedef std::list<VertexImpl*> type;
- };
-};
-// etc. special provision will be made for intrusive containers and their
-// magical polymorphic qualities in the next level...
-
-
-} // fusion_graph
-} // metagraoh
-} // boost

Copied: sandbox/metagraph/boost/metagraph/fusion_graph/fusion_graph.hpp (from r48383, /sandbox/metagraph/boost/metagraph/fusion_graph/fusion_graph.h)
==============================================================================
--- /sandbox/metagraph/boost/metagraph/fusion_graph/fusion_graph.h (original)
+++ sandbox/metagraph/boost/metagraph/fusion_graph/fusion_graph.hpp 2008-08-25 14:12:11 EDT (Mon, 25 Aug 2008)
@@ -5,7 +5,7 @@
 // (See accompanying file LICENSEmpl::_1_0.txt or copy at
 // http://www.boost.org/LICENSEmpl::_1_0.txt)
 
-#include <boost/metagraph/mpl_graph/mpl_graph.h>
+#include <boost/metagraph/mpl_graph/mpl_graph.hpp>
 
 #include <boost/fusion/include/map.hpp>
 #include <boost/fusion/include/pair.hpp>

Copied: sandbox/metagraph/boost/metagraph/mpl_graph/depth_first_search.hpp (from r48383, /sandbox/metagraph/boost/metagraph/mpl_graph/dfs.hpp)
==============================================================================
--- /sandbox/metagraph/boost/metagraph/mpl_graph/dfs.hpp (original)
+++ sandbox/metagraph/boost/metagraph/mpl_graph/depth_first_search.hpp 2008-08-25 14:12:11 EDT (Mon, 25 Aug 2008)
@@ -1,4 +1,4 @@
-#include <boost/metagraph/mpl_graph/mpl_graph.h>
+#include <boost/metagraph/mpl_graph/mpl_graph.hpp>
 
 #include <boost/mpl/has_key.hpp>
 

Deleted: sandbox/metagraph/boost/metagraph/mpl_graph/dfs.hpp
==============================================================================
--- sandbox/metagraph/boost/metagraph/mpl_graph/dfs.hpp 2008-08-25 14:12:11 EDT (Mon, 25 Aug 2008)
+++ (empty file)
@@ -1,108 +0,0 @@
-#include <boost/metagraph/mpl_graph/mpl_graph.h>
-
-#include <boost/mpl/has_key.hpp>
-
-namespace boost {
-namespace metagraph {
-namespace mpl_graph {
-
-struct dfs_colors {
- struct White {};
- struct Grey {};
- struct Black {};
-};
-
-// as with all mpl algorithms, state must be carried along
-// because metadata is immutable. so we do something like the mpl inserter pattern,
-// only there are many operations, which we stick in a blob (? not sure how to avoid this)
-template<typename State, typename Operations>
-struct state_and_operations {
- typedef State state;
- typedef Operations operations;
-};
-
-// dfs takes a visitor which has all the bgl-like metafunctions encapsulated in an
-// "operations" member class, and also a state. the operations are expected to return a new state
-// in addition, the visitor operations are expected to update the colors of vertices
-// and need to support a new metafunction get_color<Node, State>
-
-struct dfs_default_visitor_operations {
- template<typename Node, typename Graph, typename State>
- struct initialize_vertex {
- typedef State type;
- };
-
- template<typename Node, typename Graph, typename State>
- struct discover_vertex {
- typedef State type;
- };
-
- template<typename Node, typename Graph, typename State>
- struct finish_vertex {
- typedef State type;
- };
-
- template<typename Edge, typename Graph, typename State>
- struct tree_edge {
- typedef State type;
- };
- template<typename Edge, typename Graph, typename State>
- struct back_edge {
- typedef State type;
- };
- template<typename Edge, typename Graph, typename State>
- struct forward_or_cross_edge {
- typedef State type;
- };
-};
-
-struct dfs_color_map_operations {
- template<typename Node, typename Color, typename State>
- struct set_color :
- mpl::insert<State, mpl::pair<Node, Color> >
- {};
- template<typename Node, typename State>
- struct get_color :
- mpl::if_<mpl::has_key<State, Node>,
- mpl::at<State, Node>,
- dfs_colors::White>
- {};
-};
-
-// visitor is operations, state as described above
-// however this returns pair< visitor_state, color_state >
-template<typename Graph, typename Node, typename Visitor,
- typename ColorMap = state_and_operations<mpl::map<>, dfs_color_map_operations> >
-struct dfs_visit {
- // enter vertex
- typedef typename Visitor::operations::template discover_vertex<Node, Graph, typename Visitor::state>::type discovered_state;
- typedef typename ColorMap::operations::template set_color<Node, dfs_colors::Grey, typename ColorMap::state>::type discovered_colors;
- // loop over out edges
- typedef typename mpl::template
- fold<typename mpl_graph::out_edges<Node, Graph>::type,
- mpl::pair<discovered_state, discovered_colors>,
- mpl::if_<boost::is_same<typename ColorMap::operations::template get_color<mpl_graph::target<mpl::_2, Graph>, mpl::second<mpl::_1 > >,
- dfs_colors::White>,
- // unseen target: recurse
- dfs_visit<Graph,
- mpl_graph::target<mpl::_2, Graph>,
- state_and_operations<typename Visitor::operations::template tree_edge<mpl::_2, Graph, mpl::first<mpl::_1> >,
- typename Visitor::operations>,
- state_and_operations<mpl::second<mpl::_1>, typename ColorMap::operations> >,
- // seen: back or forward edge
- mpl::pair<mpl::if_<boost::is_same<typename ColorMap::operations::template get_color<mpl_graph::target<mpl::_2, Graph>, mpl::second<mpl::_1 > >, dfs_colors::Grey>,
- typename Visitor::operations::template back_edge<mpl::_2, Graph, mpl::first<mpl::_1> >,
- typename Visitor::operations::template forward_or_cross_edge<mpl::_2, Graph, mpl::first<mpl::_1> > >,
- mpl::second<mpl::_1> >
- >
- >::type visited_state_and_colors;
- // leave vertex, and done!
- typedef mpl::pair<typename Visitor::operations::template finish_vertex<Node, Graph, typename mpl::first<visited_state_and_colors>::type >::type,
- typename ColorMap::operations::template set_color<Node, dfs_colors::Black, typename mpl::second<visited_state_and_colors>::type>::type> type;
-};
-
-} // namespace mpl_graph
-} // namespace metagraph
-} // namespace boost
-
-

Deleted: sandbox/metagraph/boost/metagraph/mpl_graph/mpl_graph.h
==============================================================================
--- sandbox/metagraph/boost/metagraph/mpl_graph/mpl_graph.h 2008-08-25 14:12:11 EDT (Mon, 25 Aug 2008)
+++ (empty file)
@@ -1,205 +0,0 @@
-// mpl_graph - defines a metadata implementation of the BGL immutable graph concepts
-
-// (c) 2008 Gordon Woodhull
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSEmpl::_1_0.txt or copy at
-// http://www.boost.org/LICENSEmpl::_1_0.txt)
-
-#ifndef BOOST_MPLGRAPH_H
-#define BOOST_MPLGRAPH_H
-
-#include <boost/mpl/map.hpp>
-#include <boost/mpl/vector.hpp>
-#include <boost/mpl/copy.hpp>
-#include <boost/mpl/vector.hpp>
-#include <boost/mpl/next.hpp>
-#include <boost/mpl/front.hpp>
-#include <boost/mpl/back.hpp>
-#include <boost/mpl/deref.hpp>
-#include <boost/mpl/if.hpp>
-#include <boost/mpl/size.hpp>
-#include <boost/mpl/void.hpp>
-#include <boost/mpl/erase_key.hpp>
-#include <boost/mpl/has_key.hpp>
-#include <boost/mpl/inserter.hpp>
-#include <boost/mpl/back_inserter.hpp>
-#include <boost/mpl/set.hpp>
-#include <boost/mpl/insert.hpp>
-#include <boost/mpl/transform.hpp>
-#include <boost/mpl/pair.hpp>
-#include <boost/mpl/size.hpp>
-#include <boost/mpl/fold.hpp>
-#include <boost/mpl/transform.hpp>
-#include <boost/mpl/at.hpp>
-#include <boost/mpl/push_back.hpp>
-#include <boost/mpl/filter_view.hpp>
-#include <boost/mpl/equal.hpp>
-#include <boost/type_traits.hpp>
-
-
-namespace boost {
-namespace metagraph {
-namespace mpl_graph {
-
-// idea is to lazily produce maps and other metadata structures
-// for looking up the various things U want to look up thru bgl-like interfaces
-
-// currently Edge types must be unique but it might make sense to make them
-// unique per Source and/or Target (which would require a different edge_descriptor)
-
-// also this doesn't provide for vertices with no edges
-
-// edgeseq_graph takes an mpl sequence of sequences <Edge,Source,Target> and wraps it
-// so that the rest of the code knows what it is
-// edgeseq_graph doesn't do anything but label the data as usable by the metafunctions below
-// and provide indirection for other possible input formats (?)
-template<typename EdgeSequence>
-struct edgeseq_graph {
- typedef EdgeSequence est_sequence;
-};
-
-namespace detail {
- // clarifiers
- template<typename EST> struct fetch_edge :
- mpl::front<EST> {};
- template<typename EST> struct fetch_source :
- mpl::deref<typename mpl::next<typename mpl::begin<EST>::type>::type> {};
- template<typename EST> struct fetch_target :
- mpl::back<EST> {};
-
- // S->E->T map for out_*, adjacent_vertices
- /*
- // this implementation didn't work on msvc - anyway not sure if it's more efficient
- // to build all maps at once at the expense of lots of map updates, or to use
- // the many pass, easier-to-read filter-and-build algs below.
- template<typename EdgeSeqGraph>
- struct produce_outs_map :
-
- fold<typename EdgeSeqGraph::est_sequence,
- map<>,
- if_<has_key<mpl::_1,fetch_source<mpl::_2> >,
- insert<erase_key<mpl::_1,fetch_source<mpl::_2> >,
- pair<fetch_source<mpl::_2>,
- insert<at<mpl::_1,fetch_source<mpl::_2> >,
- pair<fetch_edge<mpl::_2>, fetch_target<mpl::_2> > > > >,
- insert<mpl::_1,pair<fetch_source<mpl::_2>,
- map<pair<fetch_edge<mpl::_2>,fetch_target<mpl::_2> > > > >
- > >
- {};
- */
- // E->T map for an S for out_*, adjacent_vertices
- template<typename S, typename EdgeSeqGraph>
- struct produce_out_map :
- mpl::fold<typename mpl::filter_view<typename EdgeSeqGraph::est_sequence, boost::is_same<fetch_source<mpl::_1>,S> >::type,
- mpl::map<>,
- mpl::insert<mpl::_1,mpl::pair<fetch_edge<mpl::_2>,fetch_target<mpl::_2> > > >
- {};
- // E->S map for a T for in_*, degree
- template<typename T, typename EdgeSeqGraph>
- struct produce_in_map :
- mpl::fold<typename mpl::filter_view<typename EdgeSeqGraph::est_sequence,
- boost::is_same<fetch_target<mpl::_1>,T> >::type,
- mpl::map<>,
- mpl::insert<mpl::_1,mpl::pair<fetch_edge<mpl::_2>,fetch_source<mpl::_2> > > >
-
- {};
- // E->pair<S,T> map for source, target
- template<typename EdgeSeqGraph>
- struct produce_edge_st_map :
- mpl::fold<typename EdgeSeqGraph::est_sequence,
- mpl::map<>,
- mpl::insert<mpl::_1,mpl::pair<fetch_edge<mpl::_2>,
- mpl::pair<fetch_source<mpl::_2>,
- fetch_target<mpl::_2> > > > >
- {};
- // Vertex set for VertexListGraph
- template<typename EdgeSeqGraph>
- struct produce_vertex_set :
- mpl::fold<typename EdgeSeqGraph::est_sequence,
- typename mpl::fold<typename EdgeSeqGraph::est_sequence,
- mpl::set<>,
- mpl::insert<mpl::_1,fetch_target<mpl::_2> >
- >::type,
- mpl::insert<mpl::_1, fetch_source<mpl::_2> > >
- {};
- // Edge set for EdgeListGraph
- template<typename EdgeSeqGraph>
- struct produce_edge_set :
- mpl::fold<typename EdgeSeqGraph::est_sequence,
- mpl::set<>,
- mpl::insert<mpl::_1,fetch_edge<mpl::_2> > >
- {};
-}
-
-// Boost Graph concepts, MPL style
-
-// IncidenceGraph
-template<typename E, typename G>
-struct source :
- mpl::first<typename mpl::at<typename detail::produce_edge_st_map<G>::type,E>::type>
-{};
-template<typename E, typename G>
-struct target :
- mpl::second<typename mpl::at<typename detail::produce_edge_st_map<G>::type,E>::type>
-{};
-template<typename U, typename G>
-struct out_edges :
- mpl::fold<typename detail::produce_out_map<U,G>::type,
- mpl::vector<>,
- mpl::push_back<mpl::_1, mpl::first<mpl::_2> > >
-{};
-template<typename U, typename G>
-struct out_degree :
- mpl::size<typename out_edges<U,G>::type>
-{};
-
-// BidirectionalGraph
-template<typename V, typename G>
-struct in_edges :
- mpl::fold<typename detail::produce_in_map<V,G>::type,
- mpl::vector<>,
- mpl::push_back<mpl::_1, mpl::first<mpl::_2> > >
-{};
-template<typename V, typename G>
-struct in_degree :
- mpl::size<typename in_edges<V,G>::type>
-{};
-template<typename V, typename G>
-struct degree :
- mpl::plus<typename out_degree<V,G>::type,typename in_degree<V,G>::type>
-{};
-
-// AdjacencyGraph
-template<typename V, typename G>
-struct adjacent_vertices :
- mpl::transform<typename detail::produce_out_map<V,G>::type,
- mpl::second<mpl::_1>,
- mpl::back_inserter<mpl::vector<> > >
-{};
-
-// VertexListGraph
-template<typename G>
-struct vertices :
- detail::produce_vertex_set<G>
-{};
-template<typename G>
-struct num_vertices :
- mpl::size<typename vertices<G>::type>
-{};
-
-// EdgeListGraph
-template<typename G>
-struct edges :
- detail::produce_edge_set<G>
-{};
-template<typename G>
-struct num_edges :
- mpl::size<typename edges<G>::type>
-{};
-// source and target are defined in IncidenceGraph
-
-} // mplgraph
-} // metagraph
-} // boost
-
-#endif // BOOST_MPLGRAPH_H

Deleted: sandbox/metagraph/libs/metagraph/example/dfs.cpp
==============================================================================
--- sandbox/metagraph/libs/metagraph/example/dfs.cpp 2008-08-25 14:12:11 EDT (Mon, 25 Aug 2008)
+++ (empty file)
@@ -1,55 +0,0 @@
-#include <boost/metagraph/mpl_graph/depth_first_search.hpp>
-#include <boost/mpl/print.hpp>
-
-#include <iostream>
-
-namespace mpl_graph = boost::metagraph::mpl_graph;
-namespace mpl = boost::mpl;
-
-/*
- test graph:
- A -> B -> C -\--> D
- \ |--> E
- \ \--> F
- \-----/
-*/
-
-// vertices
-struct A{}; struct B{}; struct C{}; struct D{}; struct E{}; struct F{};
-
-// edges
-struct A_B{}; struct B_C{}; struct C_D{}; struct C_E{}; struct C_F{}; struct B_F{};
-
-typedef mpl::vector<mpl::vector<A_B,A,B>,
- mpl::vector<B_C,B,C>,
- mpl::vector<C_D,C,D>,
- mpl::vector<C_E,C,E>,
- mpl::vector<C_F,C,F>,
- mpl::vector<B_F,B,F> >
- some_edge_sequence;
-typedef mpl_graph::edgeseq_graph<some_edge_sequence> some_graph;
-
-struct preordering : mpl_graph::dfs_default_visitor_operations {
- template<typename Node, typename Graph, typename State>
- struct discover_vertex :
- mpl::push_back<State, Node>
- {};
-};
-
-struct postordering : mpl_graph::dfs_default_visitor_operations {
- template<typename Node, typename Graph, typename State>
- struct finish_vertex :
- mpl::push_back<State, Node>
- {};
-};
-
-template<typename T> struct incomplete;
-
-int main() {
- typedef mpl::first<mpl_graph::dfs_visit<some_graph,A,mpl_graph::state_and_operations<mpl::vector<>, preordering > >::type>::type preorder;
- BOOST_MPL_ASSERT(( mpl::equal<preorder::type, mpl::vector<A,B,C,D,E,F> > ));
-
- typedef mpl::first<mpl_graph::dfs_visit<some_graph,A,mpl_graph::state_and_operations<mpl::vector<>, postordering > >::type>::type postorder;
- BOOST_MPL_ASSERT(( mpl::equal<postorder::type, mpl::vector<D,E,F,C,B,A> > ));
- return 0;
-}
\ No newline at end of file

Modified: sandbox/metagraph/libs/metagraph/example/fusion_graph.cpp
==============================================================================
--- sandbox/metagraph/libs/metagraph/example/fusion_graph.cpp (original)
+++ sandbox/metagraph/libs/metagraph/example/fusion_graph.cpp 2008-08-25 14:12:11 EDT (Mon, 25 Aug 2008)
@@ -1,4 +1,4 @@
-#include <boost/metagraph/fusion_graph/fusion_graph.h>
+#include <boost/metagraph/fusion_graph/fusion_graph.hpp>
 #include <boost/mpl/print.hpp>
 
 namespace fusion_graph = boost::metagraph::fusion_graph;

Modified: sandbox/metagraph/libs/metagraph/example/mpl_graph.cpp
==============================================================================
--- sandbox/metagraph/libs/metagraph/example/mpl_graph.cpp (original)
+++ sandbox/metagraph/libs/metagraph/example/mpl_graph.cpp 2008-08-25 14:12:11 EDT (Mon, 25 Aug 2008)
@@ -1,7 +1,7 @@
 // mplgraph.cpp : Defines the entry point for the console application.
 //
 
-#include <boost/metagraph/mpl_graph/mpl_graph.h>
+#include <boost/metagraph/mpl_graph/mpl_graph.hpp>
 #include <boost/mpl/print.hpp>
 
 namespace mpl_graph = boost::metagraph::mpl_graph;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk