Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76779 - in trunk/libs/graph: doc example
From: jewillco_at_[hidden]
Date: 2012-01-29 16:08:41


Author: jewillco
Date: 2012-01-29 16:08:40 EST (Sun, 29 Jan 2012)
New Revision: 76779
URL: http://svn.boost.org/trac/boost/changeset/76779

Log:
Added documentation and examples from David Doria
Added:
   trunk/libs/graph/doc/undirected_graph.html (contents, props changed)
   trunk/libs/graph/example/directed_graph.cpp (contents, props changed)
   trunk/libs/graph/example/undirected_adjacency_list.cpp
      - copied unchanged from r76729, /trunk/libs/graph/example/undirected.cpp
   trunk/libs/graph/example/undirected_adjacency_list.expected
      - copied unchanged from r76729, /trunk/libs/graph/example/undirected.expected
   trunk/libs/graph/example/undirected_graph.cpp (contents, props changed)
Removed:
   trunk/libs/graph/example/undirected.cpp
   trunk/libs/graph/example/undirected.expected
Text files modified:
   trunk/libs/graph/doc/directed_graph.html | 96 ++++++++++++++++++++++++++++++++++++++++
   trunk/libs/graph/example/Jamfile.v2 | 3 +
   2 files changed, 99 insertions(+), 0 deletions(-)

Modified: trunk/libs/graph/doc/directed_graph.html
==============================================================================
--- trunk/libs/graph/doc/directed_graph.html (original)
+++ trunk/libs/graph/doc/directed_graph.html 2012-01-29 16:08:40 EST (Sun, 29 Jan 2012)
@@ -1,5 +1,101 @@
 <HTML>
 <!--
+ Copyright (c) David Doria 2012
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+ -->
+<Head>
+<Title>Boost Graph Library: Directed Graph</Title>
+<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
+ ALINK="#ff0000">
+<IMG SRC="../../../boost.png"
+ ALT="C++ Boost" width="277" height="86">
+
+<BR Clear>
+
+<H1><A NAME="sec:directed-graph-class"></A>
+<pre>
+directed_graph&lt;VertexProp, EdgeProp, GraphProp&gt;
+</pre>
+</H1>
+
+
+<P>
+The <tt>directed_graph</tt> class template is is a simplified version
+of the BGL adjacency list. This class is provided for ease of use, but
+may not perform as well as custom-defined adjacency list classes. Instances
+of this template model the BidirectionalGraph, VertexIndexGraph, and
+EdgeIndexGraph concepts.
+
+<H3>Example</H3>
+
+A simple examples of creating a directed_graph is available here libs/graph/example/directed_graph.cpp.
+<P>
+
+
+<PRE>
+ typedef boost::directed_graph<> Graph;
+ Graph g;
+ boost::graph_traits<Graph>::vertex_descriptor v0 = g.add_vertex();
+ boost::graph_traits<Graph>::vertex_descriptor v1 = g.add_vertex();
+
+ g.add_edge(v0, v1);
+</PRE>
+
+<H3>Template Parameters</H3>
+
+<P>
+<TABLE border>
+<TR>
+<th>Parameter</th><th>Description</th><th>Default</th>
+</tr>
+
+<TR><TD><TT>VertexProp</TT></TD>
+<TD>A property map for the graph vertices.</TD>
+<TD>&nbsp;</TD>
+</TR>
+
+<TR>
+<TD><TT>EdgeProp</TT></TD>
+<TD>A property map for the graph edges.</TD>
+<TD>&nbsp;</TD>
+</TR>
+
+<TR>
+<TD><TT>GraphProp</TT></TD>
+<TD>A property map for the graph itself.</TD>
+</TR>
+
+</TABLE>
+<P>
+
+<H3>Where Defined</H3>
+
+<P>
+boost/graph/directed_graph.hpp
+
+<P>
+
+<br>
+<HR>
+<TABLE>
+<TR valign=top>
+<TD nowrap>Copyright &copy; 2000-2001</TD><TD>
+Jeremy Siek,
+Indiana University (<A
+HREF="mailto:jsiek_at_[hidden]">jsiek_at_[hidden]</A>)<br>
+<A HREF="http://www.boost.org/people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee_at_[hidden]">llee_at_[hidden]</A>)<br>
+Andrew Lumsdaine,
+Indiana University (<A
+HREF="mailto:lums_at_[hidden]">lums_at_[hidden]</A>)
+</TD></TR></TABLE>
+
+</BODY>
+</HTML>
+<HTML>
+<!--
      Copyright (c) Jeremy Siek 2000
     
      Distributed under the Boost Software License, Version 1.0.

Added: trunk/libs/graph/doc/undirected_graph.html
==============================================================================
--- (empty file)
+++ trunk/libs/graph/doc/undirected_graph.html 2012-01-29 16:08:40 EST (Sun, 29 Jan 2012)
@@ -0,0 +1,96 @@
+<HTML>
+<!--
+ Copyright (c) David Doria 2012
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+ -->
+<Head>
+<Title>Boost Graph Library: Undirected Graph</Title>
+<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
+ ALINK="#ff0000">
+<IMG SRC="../../../boost.png"
+ ALT="C++ Boost" width="277" height="86">
+
+<BR Clear>
+
+<H1><A NAME="sec:undirected-graph-class"></A>
+<pre>
+undirected_graph&lt;VertexProp, EdgeProp, GraphProp&gt;
+</pre>
+</H1>
+
+
+<P>
+The <tt>undirected_graph</tt> class template is is a simplified version
+of the BGL adjacency list. This class is provided for ease of use, but
+may not perform as well as custom-defined adjacency list classes. Instances
+of this template model the BidirectionalGraph, VertexIndexGraph, and
+EdgeIndexGraph concepts.
+
+<H3>Example</H3>
+
+A simple example of creating an undirected_graph is available here libs/graph/example/undirected_graph.cpp
+<P>
+
+
+<PRE>
+ typedef boost::undirected_graph<> Graph;
+ Graph g;
+ boost::graph_traits<Graph>::vertex_descriptor v0 = g.add_vertex();
+ boost::graph_traits<Graph>::vertex_descriptor v1 = g.add_vertex();
+
+ g.add_edge(v0, v1);
+</PRE>
+
+<H3>Template Parameters</H3>
+
+<P>
+<TABLE border>
+<TR>
+<th>Parameter</th><th>Description</th><th>Default</th>
+</tr>
+
+<TR><TD><TT>VertexProp</TT></TD>
+<TD>A property map for the graph vertices.</TD>
+<TD>&nbsp;</TD>
+</TR>
+
+<TR>
+<TD><TT>EdgeProp</TT></TD>
+<TD>A property map for the graph edges.</TD>
+<TD>&nbsp;</TD>
+</TR>
+
+<TR>
+<TD><TT>GraphProp</TT></TD>
+<TD>A property map for the graph itself.</TD>
+</TR>
+
+</TABLE>
+<P>
+
+<H3>Where Defined</H3>
+
+<P>
+boost/graph/undirected_graph.hpp
+
+<P>
+
+<br>
+<HR>
+<TABLE>
+<TR valign=top>
+<TD nowrap>Copyright &copy; 2000-2001</TD><TD>
+Jeremy Siek,
+Indiana University (<A
+HREF="mailto:jsiek_at_[hidden]">jsiek_at_[hidden]</A>)<br>
+<A HREF="http://www.boost.org/people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee_at_[hidden]">llee_at_[hidden]</A>)<br>
+Andrew Lumsdaine,
+Indiana University (<A
+HREF="mailto:lums_at_[hidden]">lums_at_[hidden]</A>)
+</TD></TR></TABLE>
+
+</BODY>
+</HTML>

Modified: trunk/libs/graph/example/Jamfile.v2
==============================================================================
--- trunk/libs/graph/example/Jamfile.v2 (original)
+++ trunk/libs/graph/example/Jamfile.v2 2012-01-29 16:08:40 EST (Sun, 29 Jan 2012)
@@ -35,3 +35,6 @@
 exe bfs-example2 : bfs-example2.cpp ;
 exe dfs-example : dfs-example.cpp ;
 exe adjacency_list_io : adjacency_list_io.cpp ;
+exe undirected_adjacency_list : undirected_adjacency_list.cpp ;
+exe directed_graph : directed_graph.cpp ;
+exe undirected_graph : undirected_graph.cpp ;

Added: trunk/libs/graph/example/directed_graph.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/graph/example/directed_graph.cpp 2012-01-29 16:08:40 EST (Sun, 29 Jan 2012)
@@ -0,0 +1,26 @@
+//=======================================================================
+// Copyright 2012
+// Authors: David Doria
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//=======================================================================
+
+#include <boost/graph/directed_graph.hpp> // A subclass to provide reasonable arguments to adjacency_list for a typical directed graph
+
+int main(int,char*[])
+{
+ // directed_graph is a subclass of adjacency_list which gives you object oriented access to functions
+ // like add_vertex and add_edge, which makes the code easier to understand. However, it hard codes many
+ // of the template parameters, so it is much less flexible.
+
+ typedef boost::directed_graph<> Graph;
+ Graph g;
+ boost::graph_traits<Graph>::vertex_descriptor v0 = g.add_vertex();
+ boost::graph_traits<Graph>::vertex_descriptor v1 = g.add_vertex();
+
+ g.add_edge(v0, v1);
+
+ return 0;
+}

Deleted: trunk/libs/graph/example/undirected.cpp
==============================================================================
--- trunk/libs/graph/example/undirected.cpp 2012-01-29 16:08:40 EST (Sun, 29 Jan 2012)
+++ (empty file)
@@ -1,109 +0,0 @@
-//=======================================================================
-// Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee,
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//=======================================================================
-#include <boost/config.hpp>
-#include <iostream>
-#include <boost/graph/adjacency_list.hpp>
-using namespace boost;
-
-template < typename UndirectedGraph > void
-undirected_graph_demo1()
-{
- const int V = 3;
- UndirectedGraph undigraph(V);
- typename graph_traits < UndirectedGraph >::vertex_descriptor zero, one, two;
- typename graph_traits < UndirectedGraph >::out_edge_iterator out, out_end;
- typename graph_traits < UndirectedGraph >::in_edge_iterator in, in_end;
-
- zero = vertex(0, undigraph);
- one = vertex(1, undigraph);
- two = vertex(2, undigraph);
- add_edge(zero, one, undigraph);
- add_edge(zero, two, undigraph);
- add_edge(one, two, undigraph);
-
- std::cout << "out_edges(0): ";
- for (boost::tie(out, out_end) = out_edges(zero, undigraph); out != out_end; ++out)
- std::cout << *out;
- std::cout << std::endl << "in_edges(0): ";
- for (boost::tie(in, in_end) = in_edges(zero, undigraph); in != in_end; ++in)
- std::cout << *in;
- std::cout << std::endl;
-}
-
-template < typename DirectedGraph > void
-directed_graph_demo()
-{
- const int V = 2;
- DirectedGraph digraph(V);
- typename graph_traits < DirectedGraph >::vertex_descriptor u, v;
- typedef typename DirectedGraph::edge_property_type Weight;
- typename property_map < DirectedGraph, edge_weight_t >::type
- weight = get(edge_weight, digraph);
- typename graph_traits < DirectedGraph >::edge_descriptor e1, e2;
- bool found;
-
- u = vertex(0, digraph);
- v = vertex(1, digraph);
- add_edge(u, v, Weight(1.2), digraph);
- add_edge(v, u, Weight(2.4), digraph);
- boost::tie(e1, found) = edge(u, v, digraph);
- boost::tie(e2, found) = edge(v, u, digraph);
- std::cout << "in a directed graph is ";
-#ifdef __GNUC__
- // no boolalpha
- std::cout << "(u,v) == (v,u) ? " << (e1 == e2) << std::endl;
-#else
- std::cout << "(u,v) == (v,u) ? "
- << std::boolalpha << (e1 == e2) << std::endl;
-#endif
- std::cout << "weight[(u,v)] = " << get(weight, e1) << std::endl;
- std::cout << "weight[(v,u)] = " << get(weight, e2) << std::endl;
-}
-
-template < typename UndirectedGraph > void
-undirected_graph_demo2()
-{
- const int V = 2;
- UndirectedGraph undigraph(V);
- typename graph_traits < UndirectedGraph >::vertex_descriptor u, v;
- typedef typename UndirectedGraph::edge_property_type Weight;
- typename property_map < UndirectedGraph, edge_weight_t >::type
- weight = get(edge_weight, undigraph);
- typename graph_traits < UndirectedGraph >::edge_descriptor e1, e2;
- bool found;
-
- u = vertex(0, undigraph);
- v = vertex(1, undigraph);
- add_edge(u, v, Weight(3.1), undigraph);
- boost::tie(e1, found) = edge(u, v, undigraph);
- boost::tie(e2, found) = edge(v, u, undigraph);
- std::cout << "in an undirected graph is ";
-#ifdef __GNUC__
- std::cout << "(u,v) == (v,u) ? " << (e1 == e2) << std::endl;
-#else
- std::cout << "(u,v) == (v,u) ? "
- << std::boolalpha << (e1 == e2) << std::endl;
-#endif
- std::cout << "weight[(u,v)] = " << get(weight, e1) << std::endl;
- std::cout << "weight[(v,u)] = " << get(weight, e2) << std::endl;
-}
-
-
-int
-main()
-{
- typedef property < edge_weight_t, double >Weight;
- typedef adjacency_list < vecS, vecS, undirectedS,
- no_property, Weight > UndirectedGraph;
- typedef adjacency_list < vecS, vecS, directedS,
- no_property, Weight > DirectedGraph;
- undirected_graph_demo1 < UndirectedGraph > ();
- undirected_graph_demo2 < UndirectedGraph > ();
- directed_graph_demo < DirectedGraph > ();
- return 0;
-}

Deleted: trunk/libs/graph/example/undirected.expected
==============================================================================
--- trunk/libs/graph/example/undirected.expected 2012-01-29 16:08:40 EST (Sun, 29 Jan 2012)
+++ (empty file)
@@ -1,7 +0,0 @@
-in a directed graph is (u,v) == (v,u) ? 0
-weight[(u,v)] = 1.2
-weight[(v,u)] = 2.4
-in an undirected graph is (u,v) == (v,u) ? 1
-weight[(u,v)] = 3.1
-weight[(v,u)] = 3.1
-the edges incident to v: (0,1)

Added: trunk/libs/graph/example/undirected_graph.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/graph/example/undirected_graph.cpp 2012-01-29 16:08:40 EST (Sun, 29 Jan 2012)
@@ -0,0 +1,30 @@
+//=======================================================================
+// Copyright 2012
+// Authors: David Doria
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//=======================================================================
+
+#include <boost/graph/graph_traits.hpp>
+#include <boost/graph/undirected_graph.hpp>
+
+typedef boost::undirected_graph<boost::no_property> Graph;
+
+int main(int,char*[])
+{
+ // Create a graph object
+ Graph g;
+
+ // Add vertices
+ boost::graph_traits<Graph>::vertex_descriptor v0 = g.add_vertex();
+ boost::graph_traits<Graph>::vertex_descriptor v1 = g.add_vertex();
+ boost::graph_traits<Graph>::vertex_descriptor v2 = g.add_vertex();
+
+ // Add edges
+ g.add_edge(v0, v1);
+ g.add_edge(v1, v2);
+
+ return 0;
+}


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