Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53562 - sandbox/SOC/2009/function_graph/boost/function_graph
From: mlopez7_at_[hidden]
Date: 2009-06-01 21:42:51


Author: lopezeant
Date: 2009-06-01 21:42:50 EDT (Mon, 01 Jun 2009)
New Revision: 53562
URL: http://svn.boost.org/trac/boost/changeset/53562

Log:
Traits are being added.
Text files modified:
   sandbox/SOC/2009/function_graph/boost/function_graph/function_graph.hpp | 67 ++++++++++++++++++++++-----------------
   1 files changed, 37 insertions(+), 30 deletions(-)

Modified: sandbox/SOC/2009/function_graph/boost/function_graph/function_graph.hpp
==============================================================================
--- sandbox/SOC/2009/function_graph/boost/function_graph/function_graph.hpp (original)
+++ sandbox/SOC/2009/function_graph/boost/function_graph/function_graph.hpp 2009-06-01 21:42:50 EDT (Mon, 01 Jun 2009)
@@ -7,25 +7,20 @@
  *
  */
 
-
-
 #ifndef FUNCTION_GRAPH_HPP_
 #define FUNCTION_GRAPH_HPP_
 
+#include <boost/graph/graph_traits.hpp>
 #include <boost/function.hpp>
 #include <boost/function_types/function_arity.hpp>
+#include <utility>
 
-namespace boost { namespace graph {
+namespace boost {
 
 /**
  * function_graph_base handles the edge function. A user can define the function
  * as a boost::function, but the user may only have access to this function
  * through the function graph via edge().
- *
- * @note This version compiles. To revert to the single parameter catch,
- * uncomment lines 55, 66 and 107 - 110. This is not to take the interface
- * towards a different direction. This is only to test the function graph
- * constructors and a set_edge_function for now.
  */
 template <typename Func>
 struct function_graph_base {
@@ -33,7 +28,6 @@
     typedef Func function_type;
     typedef typename function_type::result_type edge_type;
     typedef typename function_type::first_argument_type vertex_type;
- //typedef typename function_type::second_argument_type second_vertex_type;
     
     /** Constructor - Default */
     function_graph_base()
@@ -58,16 +52,11 @@
 /**
  * Empty function graph prevents instantiations such as function_graph<int> and
  * function_graph<bool (int, int)>.
- *
- * @note [asutton] I'm defining an empty function graph so that we can create
- * specializations that force the user to provide T in certain forms. This
- * variant will be instantiated for meaningless types such as graph<int>.
- * Obviously, that should fail.
  */
 template <typename T> struct function_graph { };
 
 /**
- * function_graph is a class designed to handle implicit graphs and more.
+ * function_graph is a data structure that implements implicit graphs and more.
  * Better documentation and explanation of the data structure to come.
  *
  * @internal The typical user of function graph may not need to change edge
@@ -75,21 +64,22 @@
  * is part of the interface. Paired with it is the default constructor.
  */
 template <typename Edge, typename Vertex>
-struct function_graph <function<Edge(Vertex, Vertex)> >
+struct function_graph <function <Edge(Vertex, Vertex)> >
     : public function_graph_base <function <Edge(Vertex, Vertex)> >
 {
     typedef function_graph_base <function <Edge(Vertex, Vertex)> > Base;
 public:
-
+
     typedef typename Base::function_type function_type;
- typedef typename Base::edge_type edge_type;
- typedef typename Base::vertex_type vertex_type;
- //typedef Base::second_vertex_type second_vertex_type;
-
- /**
- * Constructor: default
- */
+ typedef typename Base::vertex_type vertex_descriptor;
+ typedef typename Base::edge_type edge_descriptor;
+ typedef directed_tag directed_category;
+ typedef disallow_parallel_edge_tag edge_parallel_category;
+ typedef adjacency_matrix_tag traversal_category;
+
+ /** Constructor: default */
     function_graph()
+ : Base()
     { }
     
     /** Constructor: takes a boost::function or functor */
@@ -97,14 +87,12 @@
         : Base(f)
     { }
     
-
     /** Set the function of the implicit graph */
     using Base::set_function;
     
+private:
     /** Edge function from Base */
     using Base::edge;
-
-private:
 };
 
 /**
@@ -114,11 +102,30 @@
  */
 
 template <typename Edge, typename Vertex>
-struct function_graph<Edge(Vertex, Vertex)>
- : private function_graph_base< function<Edge(Vertex, Vertex)> >
+struct function_graph <Edge(Vertex, Vertex)>
+ : private function_graph_base <function<Edge(Vertex, Vertex)> >
 { };
 
-} // graph namespace
+/**
+ * Direct Edge Access - Part of the adjacency matrix concept
+ * http://www.boost.org/doc/libs/1_39_0/libs/graph/doc/AdjacencyMatrix.html
+ */
+template <typename Edge, typename Vertex>
+std::pair<typename function_graph<function<Edge(Vertex, Vertex)> >
+ ::edge_descriptor, // It would look cleaner to use Edge and Vertex
+ bool>
+edge(typename function_graph<function<Edge(Vertex, Vertex)> >
+ ::vertex_descriptor u,
+ typename function_graph<function<Edge(Vertex, Vertex)> >
+ ::vertex_descriptor v,
+ function_graph<function<Edge(Vertex, Vertex)> > const& g)
+{
+ // Issue: Edge does not necessarily yield a false. The edge function needs
+ // to account for this and should return the pair.
+ //bool exists = function_graph<function<Edge(Vertex, Vertex)> >::edge(u, v)
+ //return std::make_pair(/* */, exists);
+}
+
 } // boost namespace
 
 #endif /*FUNCTION_GRAPH_HPP_*/


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