$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r53604 - sandbox/SOC/2009/function_graph/libs/test
From: mlopez7_at_[hidden]
Date: 2009-06-03 13:21:11
Author: lopezeant
Date: 2009-06-03 13:21:11 EDT (Wed, 03 Jun 2009)
New Revision: 53604
URL: http://svn.boost.org/trac/boost/changeset/53604
Log:
Adapting edge(u,v,g) into function_graph
Added:
   sandbox/SOC/2009/function_graph/libs/test/test2.cpp
      - copied, changed from r53576, /sandbox/SOC/2009/function_graph/libs/test/test1.cpp
Text files modified: 
   sandbox/SOC/2009/function_graph/libs/test/test1.cpp |    21 +++++++++++++++++----                   
   sandbox/SOC/2009/function_graph/libs/test/test2.cpp |    35 +++++++++++++++++++++++++++--------     
   2 files changed, 44 insertions(+), 12 deletions(-)
Modified: sandbox/SOC/2009/function_graph/libs/test/test1.cpp
==============================================================================
--- sandbox/SOC/2009/function_graph/libs/test/test1.cpp	(original)
+++ sandbox/SOC/2009/function_graph/libs/test/test1.cpp	2009-06-03 13:21:11 EDT (Wed, 03 Jun 2009)
@@ -1,21 +1,27 @@
+/**
+ * Testing a function that returns a boolean
+ */
+
 #include <iostream>
 #include <boost/function.hpp>
 #include <functional>
 #include <algorithm>
 #include <vector>
+#include <utility>
 #include "function_graph.hpp"
 
 template <typename T>
 struct less_than {
     bool operator()(T a, T b) { return a < b; }
-}; 
+};
 
 int main()
 {
     ////////
     // Create a boost function and function graph.
     typedef boost::function<bool(int,int)> function_type;
-    typedef boost::graph::function_graph<function_type> graph;
+    typedef boost::function_graph<function_type> graph;
+    typedef graph::edge_descriptor edge_descriptor;
     function_type f = less_than<int>();
     function_type g = less_than<int>();
     graph funcGraph(f);
@@ -27,8 +33,15 @@
     ////////
     // Check the edge output.
     std::cout << "2 < 1 check ";
-    if(funcGraph.edge(2,1)) std::cout << "passes." << "\n";
-    else std::cout << "fails." << "\n";
+    if(funcGraph.edge(2,1)) std::cout << "fails." << "\n";
+    else std::cout << "passes." << "\n";
+
+    ////////
+    // Check the adjacency matrix edge
+    std::pair<edge_descriptor, bool> edge_pair = boost::edge(1, 2, funcGraph);
+    std::cout << edge_pair.first << "\n";
+
+    
     
     return 0;
 }
Copied: sandbox/SOC/2009/function_graph/libs/test/test2.cpp (from r53576, /sandbox/SOC/2009/function_graph/libs/test/test1.cpp)
==============================================================================
--- /sandbox/SOC/2009/function_graph/libs/test/test1.cpp	(original)
+++ sandbox/SOC/2009/function_graph/libs/test/test2.cpp	2009-06-03 13:21:11 EDT (Wed, 03 Jun 2009)
@@ -1,21 +1,33 @@
+/**
+ * Testing a function that returns a type that is always used. This means
+ * the graph is closed.
+ */
+
 #include <iostream>
 #include <boost/function.hpp>
 #include <functional>
 #include <algorithm>
 #include <vector>
+#include <utility>
 #include "function_graph.hpp"
+#include <cmath>
+
+struct point {
+    double x, y;
+}
 
-template <typename T>
-struct less_than {
-    bool operator()(T a, T b) { return a < b; }
-}; 
+struct distance_2 {
+    double operator()(point a, point b)
+    { return sqrt(pow(a.x - b.x,2) + pow(a.x - b.x,2)); }
+};
 
 int main()
 {
     ////////
     // Create a boost function and function graph.
-    typedef boost::function<bool(int,int)> function_type;
-    typedef boost::graph::function_graph<function_type> graph;
+    typedef boost::function<double(int,int)> function_type;
+    typedef boost::function_graph<function_type> graph;
+    typedef graph::edge_descriptor edge_descriptor;
     function_type f = less_than<int>();
     function_type g = less_than<int>();
     graph funcGraph(f);
@@ -27,8 +39,15 @@
     ////////
     // Check the edge output.
     std::cout << "2 < 1 check ";
-    if(funcGraph.edge(2,1)) std::cout << "passes." << "\n";
-    else std::cout << "fails." << "\n";
+    if(funcGraph.edge(2,1)) std::cout << "fails." << "\n";
+    else std::cout << "passes." << "\n";
+
+    ////////
+    // Check the adjacency matrix edge
+    std::pair<edge_descriptor, bool> edge_pair = boost::edge(1, 2, funcGraph);
+    std::cout << edge_pair.first << "\n";
+
+    
     
     return 0;
 }