<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://www.programmingexamples.net/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.programmingexamples.net/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Awallin</id>
		<title>ProgrammingExamples - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://www.programmingexamples.net/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Awallin"/>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/Special:Contributions/Awallin"/>
		<updated>2026-05-25T11:52:29Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.23.5</generator>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/Boost/Math/uBLAS/determinant</id>
		<title>CPP/Boost/Math/uBLAS/determinant</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/Boost/Math/uBLAS/determinant"/>
				<updated>2011-08-14T12:27:39Z</updated>
		
		<summary type="html">&lt;p&gt;Awallin: lu_factorize determinant example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Note: if you need to calculate the determinant of a 'small' matrix (3x3 or maybe 5x5) I have found that a brute-force method is much faster than using lu_factorize().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/numeric/ublas/matrix.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/numeric/ublas/io.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/numeric/ublas/lu.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
namespace bnu = boost::numeric::ublas;&lt;br /&gt;
&lt;br /&gt;
int determinant_sign(const bnu::permutation_matrix&amp;lt;std::size_t&amp;gt;&amp;amp; pm)&lt;br /&gt;
{&lt;br /&gt;
    int pm_sign=1;&lt;br /&gt;
    std::size_t size = pm.size();&lt;br /&gt;
    for (std::size_t i = 0; i &amp;lt; size; ++i)&lt;br /&gt;
        if (i != pm(i))&lt;br /&gt;
            pm_sign *= -1.0; // swap_rows would swap a pair of rows here, so we change sign&lt;br /&gt;
    return pm_sign;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
double determinant( bnu::matrix&amp;lt;double&amp;gt;&amp;amp; m ) {&lt;br /&gt;
    bnu::permutation_matrix&amp;lt;std::size_t&amp;gt; pm(m.size1());&lt;br /&gt;
    double det = 1.0;&lt;br /&gt;
    if( bnu::lu_factorize(m,pm) ) {&lt;br /&gt;
        det = 0.0;&lt;br /&gt;
    } else {&lt;br /&gt;
        for(int i = 0; i &amp;lt; m.size1(); i++) &lt;br /&gt;
            det *= m(i,i); // multiply by elements on diagonal&lt;br /&gt;
        det = det * determinant_sign( pm );&lt;br /&gt;
    }&lt;br /&gt;
    return det;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main () {&lt;br /&gt;
    bnu::matrix&amp;lt;double&amp;gt; m(3, 3);&lt;br /&gt;
    for (unsigned i = 0; i &amp;lt; m.size1() ; ++i) {&lt;br /&gt;
        for (unsigned j = 0; j &amp;lt; m.size2() ; ++j) {&lt;br /&gt;
            m (i, j) = 3 * i + sqrt(j+1); // fill matrix&lt;br /&gt;
            m(i,j) = m(i,j)*m(i,j);       // with some numbers&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;before det() call m= &amp;quot; &amp;lt;&amp;lt; m &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    double det = determinant(m);&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;after det() call  m= &amp;quot; &amp;lt;&amp;lt; m &amp;lt;&amp;lt; std::endl; // m has changed afted determinant() call!&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;determinant=&amp;quot; &amp;lt;&amp;lt; det &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Awallin</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/Boost</id>
		<title>Boost</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/Boost"/>
				<updated>2011-08-14T12:24:29Z</updated>
		
		<summary type="html">&lt;p&gt;Awallin: /* Boost Math Library */ uBLAS determinant example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The following examples are frequent use cases of parts of the Boost (http://www.boost.org/) library. Each example includes a CMakeLists.txt file so it can be easily compiled.&lt;br /&gt;
&lt;br /&gt;
* [[CPP/Boost/Bimap|Bidirectional (both ways) map]]&lt;br /&gt;
* [[CPP/Boost/Function|Glorified function pointers (function.hpp and bind.hpp)]]&lt;br /&gt;
* [[CPP/Boost/Histogram|Create a histogram (accumulator)]]&lt;br /&gt;
* [[CPP/Boost/Numeric/Matrix|Matrix]]&lt;br /&gt;
* [[CPP/Boost/Numeric/MultiArray|Multi dimensional array]]&lt;br /&gt;
* [[CPP/Boost/ProgramOptions/Simple|Simple command line argument parsing (ProgramOptions)]]&lt;br /&gt;
* [[CPP/Boost/ProgramOptions/MultipleArguments|Multiple command line argument parsing (ProgramOptions)]]&lt;br /&gt;
* [[CPP/Boost/ProgressBar|ProgressBar]]&lt;br /&gt;
* [[CPP/Boost/Threads|Threads]]&lt;br /&gt;
* [[CPP/Boost/ThreadsMember|Threads with member functions]]&lt;br /&gt;
* [[CPP/Boost/ThreadCommunication|ThreadCommunication]]&lt;br /&gt;
* [[CPP/Boost/Timer|Timer]]&lt;br /&gt;
* [[CPP/Boost/Signals/Basic|Signal/slot pattern]]&lt;br /&gt;
* [[CPP/Boost/Signals/Class|Signal/slot pattern with member functions]]&lt;br /&gt;
* [[CPP/Boost/Signals/ClassMember|Signal/slot pattern with member classes]]&lt;br /&gt;
* [[CPP/Boost/Signals/ClassMemberWithParameters|Signal/slot pattern with member classes which have parameters]]&lt;br /&gt;
* [[CPP/Boost/Signals2/Basic|Signals2: Signal/slot pattern with type safety]]&lt;br /&gt;
* [[CPP/Boost/Signals2/Parameters|Signals2: Signal/slot pattern with parameters type safety]]&lt;br /&gt;
&lt;br /&gt;
== Boost Graph Library (BGL) ==&lt;br /&gt;
=== Basics ===&lt;br /&gt;
* [[CPP/Boost/CreateGraph|Create a graph]] - This is the most fundamental process of using BGL - creating a graph. This example explains 3 methods of creating a graph, using adjacency_list directly, and also using the directed_graph and undirected_graph subclasses.&lt;br /&gt;
* [[CPP/Boost/BGL/IterateEdges|Iterate over all edges in the graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/EdgeExists|Check if an edge exists]] - If it does, you also get the edge_descriptor&lt;br /&gt;
* [[CPP/Boost/BGL/CopyAGraph|Copy a graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/Directed/Weighted|Access an edge]]&lt;br /&gt;
* [[CPP/Boost/RemoveVertex|Remove a vertex from a graph]]&lt;br /&gt;
* [[CPP/Boost/RemoveEdge|Remove an edge from a graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/EdgeProperties|Add properties to edges]]&lt;br /&gt;
* [[CPP/Boost/BGL/VertexProperties|Add properties to vertices]]&lt;br /&gt;
* [[CPP/Boost/BGL/BundledProperties|Bundled properties]]&lt;br /&gt;
* [[CPP/Boost/BGL/AdjacentVertices|Get a list of neighboring (adjacent) vertices]]&lt;br /&gt;
* [[CPP/Boost/BGL/DirectedGraph|Directed graphs only give access to out edges]]&lt;br /&gt;
* [[CPP/Boost/BGL/BidirectionalGraph|Bidirectional graphs give access to both in and out edges]]&lt;br /&gt;
* [[CPP/Boost/BGL/NumberOfNeighbors|Number of incoming, outgoing, and total edges]]&lt;br /&gt;
* [[CPP/Boost/BGL/BreadthFirstSearch|Breadth first search (BFS with a custom visitor)]]&lt;br /&gt;
* [[CPP/Boost/BGL/MakeBFSVisitor|Breadth first search with make_bfs_visitor]]&lt;br /&gt;
* [[CPP/Boost/BGL/DepthFirstSearch|Depth first search (DFS)]]&lt;br /&gt;
&lt;br /&gt;
=== I/O ===&lt;br /&gt;
* [[CPP/Boost/BGL/ReadGraph|Read a graph from a file]]&lt;br /&gt;
* [[CPP/Boost/BGL/WriteGraph|Write a graph to a file]]&lt;br /&gt;
* [[CPP/WishList/Boost/BGL/RelabelInputVertices|Relabel input vertices read from a dot file so they match the labels used in the file]]&lt;br /&gt;
&lt;br /&gt;
=== Algorithms ===&lt;br /&gt;
&lt;br /&gt;
* [[CPP/Boost/BGL/DijkstraDirected|Find the shortest path (Dijkstra) from a specified vertex to all other vertices in a directed graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/DijkstraUndirected|Find the shortest path (Dijkstra) from a specified vertex to all other vertices in an undirected graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/DijkstraComputePath|Find the shortest path (Dijkstra) from one specified vertex to another specified vertex in a graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/BetweennessCentralityClustering|Cluster a graph using betweenness centrality]]&lt;br /&gt;
&lt;br /&gt;
=== Visualization ===&lt;br /&gt;
&lt;br /&gt;
* [[CPP/Boost/BGL/InvisibleEdges|Create a graph with invisible edges]]&lt;br /&gt;
&lt;br /&gt;
=== Wish List ===&lt;br /&gt;
Examples in this section are either shells or something is wrong with them that must be fixed before they can graduate into real examples.&lt;br /&gt;
&lt;br /&gt;
== Boost (Generic) Geometry Library ==&lt;br /&gt;
* [[CPP/Boost/Geometry/DistanceBetweenPoints|Compute the distance between two points]]&lt;br /&gt;
* [[CPP/Boost/Geometry/PointInPolygon|Determine if a point is inside of a polygon (within() function)]]&lt;br /&gt;
* [[CPP/Boost/Geometry/Simplify|Simplify a polyline]]&lt;br /&gt;
&lt;br /&gt;
== Boost Math Library ==&lt;br /&gt;
=== uBLAS ===&lt;br /&gt;
* [[CPP/Boost/Math/uBLAS/determinant]] Calculating the determinant of a matrix using boost::numeric::lu_factorize&lt;br /&gt;
=== Tools ===&lt;br /&gt;
* [[CPP/Boost/Math/Tools/brent_find_minima|brent_find_minima]] Find a bracketed minimum of a function&lt;br /&gt;
* [[CPP/Boost/Math/Tools/TOMS748|TOMS748 root finding algorithm]] Find a bracketed root(zero) of a function&lt;/div&gt;</summary>
		<author><name>Awallin</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/Boost/Math/Tools/brent_find_minima</id>
		<title>CPP/Boost/Math/Tools/brent find minima</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/Boost/Math/Tools/brent_find_minima"/>
				<updated>2011-08-14T12:10:51Z</updated>
		
		<summary type="html">&lt;p&gt;Awallin: simple brent_find_minima example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;sstream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;boost/math/tools/minima.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
double f(double x) { return x * cos(x); }&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char** argv)&lt;br /&gt;
{&lt;br /&gt;
    typedef std::pair&amp;lt;double, double&amp;gt; Result;&lt;br /&gt;
    // find a root of the function f in the interval x=[3.0, 4.0] with 20-bit precision&lt;br /&gt;
    Result r2 = boost::math::tools::brent_find_minima(f, 3.0, 4.0, 20);&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;x=&amp;quot; &amp;lt;&amp;lt; r2.first &amp;lt;&amp;lt; &amp;quot; f=&amp;quot; &amp;lt;&amp;lt; r2.second &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// output:&lt;br /&gt;
// x=3.42562 f=-3.28837&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* CMakeLists.txt&lt;br /&gt;
cmake_minimum_required(VERSION 2.6)&lt;br /&gt;
 &lt;br /&gt;
Project(brent_test)&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
FIND_PACKAGE(Boost)&lt;br /&gt;
 &lt;br /&gt;
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${Boost_INCLUDE_DIRS})&lt;br /&gt;
LINK_DIRECTORIES(${LINK_DIRECTORIES} ${Boost_LIBRARY_DIRS})&lt;br /&gt;
 &lt;br /&gt;
ADD_EXECUTABLE(brent_test main.cpp)&lt;br /&gt;
*/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Awallin</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/Boost</id>
		<title>Boost</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/Boost"/>
				<updated>2011-08-14T12:08:48Z</updated>
		
		<summary type="html">&lt;p&gt;Awallin: /* Tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The following examples are frequent use cases of parts of the Boost (http://www.boost.org/) library. Each example includes a CMakeLists.txt file so it can be easily compiled.&lt;br /&gt;
&lt;br /&gt;
* [[CPP/Boost/Bimap|Bidirectional (both ways) map]]&lt;br /&gt;
* [[CPP/Boost/Function|Glorified function pointers (function.hpp and bind.hpp)]]&lt;br /&gt;
* [[CPP/Boost/Histogram|Create a histogram (accumulator)]]&lt;br /&gt;
* [[CPP/Boost/Numeric/Matrix|Matrix]]&lt;br /&gt;
* [[CPP/Boost/Numeric/MultiArray|Multi dimensional array]]&lt;br /&gt;
* [[CPP/Boost/ProgramOptions/Simple|Simple command line argument parsing (ProgramOptions)]]&lt;br /&gt;
* [[CPP/Boost/ProgramOptions/MultipleArguments|Multiple command line argument parsing (ProgramOptions)]]&lt;br /&gt;
* [[CPP/Boost/ProgressBar|ProgressBar]]&lt;br /&gt;
* [[CPP/Boost/Threads|Threads]]&lt;br /&gt;
* [[CPP/Boost/ThreadsMember|Threads with member functions]]&lt;br /&gt;
* [[CPP/Boost/ThreadCommunication|ThreadCommunication]]&lt;br /&gt;
* [[CPP/Boost/Timer|Timer]]&lt;br /&gt;
* [[CPP/Boost/Signals/Basic|Signal/slot pattern]]&lt;br /&gt;
* [[CPP/Boost/Signals/Class|Signal/slot pattern with member functions]]&lt;br /&gt;
* [[CPP/Boost/Signals/ClassMember|Signal/slot pattern with member classes]]&lt;br /&gt;
* [[CPP/Boost/Signals/ClassMemberWithParameters|Signal/slot pattern with member classes which have parameters]]&lt;br /&gt;
* [[CPP/Boost/Signals2/Basic|Signals2: Signal/slot pattern with type safety]]&lt;br /&gt;
* [[CPP/Boost/Signals2/Parameters|Signals2: Signal/slot pattern with parameters type safety]]&lt;br /&gt;
&lt;br /&gt;
== Boost Graph Library (BGL) ==&lt;br /&gt;
=== Basics ===&lt;br /&gt;
* [[CPP/Boost/CreateGraph|Create a graph]] - This is the most fundamental process of using BGL - creating a graph. This example explains 3 methods of creating a graph, using adjacency_list directly, and also using the directed_graph and undirected_graph subclasses.&lt;br /&gt;
* [[CPP/Boost/BGL/IterateEdges|Iterate over all edges in the graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/EdgeExists|Check if an edge exists]] - If it does, you also get the edge_descriptor&lt;br /&gt;
* [[CPP/Boost/BGL/CopyAGraph|Copy a graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/Directed/Weighted|Access an edge]]&lt;br /&gt;
* [[CPP/Boost/RemoveVertex|Remove a vertex from a graph]]&lt;br /&gt;
* [[CPP/Boost/RemoveEdge|Remove an edge from a graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/EdgeProperties|Add properties to edges]]&lt;br /&gt;
* [[CPP/Boost/BGL/VertexProperties|Add properties to vertices]]&lt;br /&gt;
* [[CPP/Boost/BGL/BundledProperties|Bundled properties]]&lt;br /&gt;
* [[CPP/Boost/BGL/AdjacentVertices|Get a list of neighboring (adjacent) vertices]]&lt;br /&gt;
* [[CPP/Boost/BGL/DirectedGraph|Directed graphs only give access to out edges]]&lt;br /&gt;
* [[CPP/Boost/BGL/BidirectionalGraph|Bidirectional graphs give access to both in and out edges]]&lt;br /&gt;
* [[CPP/Boost/BGL/NumberOfNeighbors|Number of incoming, outgoing, and total edges]]&lt;br /&gt;
* [[CPP/Boost/BGL/BreadthFirstSearch|Breadth first search (BFS with a custom visitor)]]&lt;br /&gt;
* [[CPP/Boost/BGL/MakeBFSVisitor|Breadth first search with make_bfs_visitor]]&lt;br /&gt;
* [[CPP/Boost/BGL/DepthFirstSearch|Depth first search (DFS)]]&lt;br /&gt;
&lt;br /&gt;
=== I/O ===&lt;br /&gt;
* [[CPP/Boost/BGL/ReadGraph|Read a graph from a file]]&lt;br /&gt;
* [[CPP/Boost/BGL/WriteGraph|Write a graph to a file]]&lt;br /&gt;
* [[CPP/WishList/Boost/BGL/RelabelInputVertices|Relabel input vertices read from a dot file so they match the labels used in the file]]&lt;br /&gt;
&lt;br /&gt;
=== Algorithms ===&lt;br /&gt;
&lt;br /&gt;
* [[CPP/Boost/BGL/DijkstraDirected|Find the shortest path (Dijkstra) from a specified vertex to all other vertices in a directed graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/DijkstraUndirected|Find the shortest path (Dijkstra) from a specified vertex to all other vertices in an undirected graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/DijkstraComputePath|Find the shortest path (Dijkstra) from one specified vertex to another specified vertex in a graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/BetweennessCentralityClustering|Cluster a graph using betweenness centrality]]&lt;br /&gt;
&lt;br /&gt;
=== Visualization ===&lt;br /&gt;
&lt;br /&gt;
* [[CPP/Boost/BGL/InvisibleEdges|Create a graph with invisible edges]]&lt;br /&gt;
&lt;br /&gt;
=== Wish List ===&lt;br /&gt;
Examples in this section are either shells or something is wrong with them that must be fixed before they can graduate into real examples.&lt;br /&gt;
&lt;br /&gt;
== Boost (Generic) Geometry Library ==&lt;br /&gt;
* [[CPP/Boost/Geometry/DistanceBetweenPoints|Compute the distance between two points]]&lt;br /&gt;
* [[CPP/Boost/Geometry/PointInPolygon|Determine if a point is inside of a polygon (within() function)]]&lt;br /&gt;
* [[CPP/Boost/Geometry/Simplify|Simplify a polyline]]&lt;br /&gt;
&lt;br /&gt;
== Boost Math Library ==&lt;br /&gt;
=== Tools ===&lt;br /&gt;
* [[CPP/Boost/Math/Tools/brent_find_minima|brent_find_minima]] Find a bracketed minimum of a function&lt;br /&gt;
* [[CPP/Boost/Math/Tools/TOMS748|TOMS748 root finding algorithm]] Find a bracketed root(zero) of a function&lt;/div&gt;</summary>
		<author><name>Awallin</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/CPP/Boost/Math/Tools/TOMS748</id>
		<title>CPP/Boost/Math/Tools/TOMS748</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/CPP/Boost/Math/Tools/TOMS748"/>
				<updated>2011-08-14T12:05:15Z</updated>
		
		<summary type="html">&lt;p&gt;Awallin: Created page with '&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt; #include &amp;lt;iostream&amp;gt; #include &amp;lt;sstream&amp;gt; #include &amp;lt;string&amp;gt;   #include &amp;lt;boost/math/tools/roots.hpp&amp;gt;  class Test { public:     double operator()(const do…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;sstream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;boost/math/tools/roots.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class Test {&lt;br /&gt;
public:&lt;br /&gt;
    double operator()(const double x) {&lt;br /&gt;
        return x * cos(x);&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
// see: &lt;br /&gt;
// http://www.boost.org/doc/libs/1_47_0/libs/math/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/roots2.html&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char** argv) {&lt;br /&gt;
    Test t;&lt;br /&gt;
    typedef std::pair&amp;lt;double, double&amp;gt; Result;&lt;br /&gt;
    boost::uintmax_t max_iter=500;&lt;br /&gt;
    boost::math::tools::eps_tolerance&amp;lt;double&amp;gt; tol(30);&lt;br /&gt;
&lt;br /&gt;
    Result r1 = boost::math::tools::toms748_solve(t, 1.0, 2.0, tol, max_iter);&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;root bracketed: [ &amp;quot; &amp;lt;&amp;lt; r1.first &amp;lt;&amp;lt; &amp;quot; , &amp;quot; &amp;lt;&amp;lt; r1.second &amp;lt;&amp;lt;  &amp;quot; ]&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;f(&amp;quot;&amp;lt;&amp;lt; r1.first &amp;lt;&amp;lt; &amp;quot;)=&amp;quot; &amp;lt;&amp;lt; t(r1.first) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;f(&amp;quot;&amp;lt;&amp;lt; r1.second &amp;lt;&amp;lt; &amp;quot;)=&amp;quot; &amp;lt;&amp;lt; t(r1.second) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;max_iter=&amp;quot; &amp;lt;&amp;lt; max_iter &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Output:&lt;br /&gt;
root bracketed: [ 1.5708 , 1.5708 ]&lt;br /&gt;
f(1.5708)=9.61835e-17&lt;br /&gt;
f(1.5708)=-1.99654e-15&lt;br /&gt;
max_iter=9&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
/* CMakeLists.txt: &lt;br /&gt;
cmake_minimum_required(VERSION 2.6) &lt;br /&gt;
Project(toms748_test)&lt;br /&gt;
FIND_PACKAGE(Boost)&lt;br /&gt;
 &lt;br /&gt;
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${Boost_INCLUDE_DIRS})&lt;br /&gt;
LINK_DIRECTORIES(${LINK_DIRECTORIES} ${Boost_LIBRARY_DIRS})&lt;br /&gt;
 &lt;br /&gt;
ADD_EXECUTABLE(toms748_test main.cpp)&lt;br /&gt;
*/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Awallin</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/Boost</id>
		<title>Boost</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/Boost"/>
				<updated>2011-08-14T12:04:45Z</updated>
		
		<summary type="html">&lt;p&gt;Awallin: correct algorithm name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The following examples are frequent use cases of parts of the Boost (http://www.boost.org/) library. Each example includes a CMakeLists.txt file so it can be easily compiled.&lt;br /&gt;
&lt;br /&gt;
* [[CPP/Boost/Bimap|Bidirectional (both ways) map]]&lt;br /&gt;
* [[CPP/Boost/Function|Glorified function pointers (function.hpp and bind.hpp)]]&lt;br /&gt;
* [[CPP/Boost/Histogram|Create a histogram (accumulator)]]&lt;br /&gt;
* [[CPP/Boost/Numeric/Matrix|Matrix]]&lt;br /&gt;
* [[CPP/Boost/Numeric/MultiArray|Multi dimensional array]]&lt;br /&gt;
* [[CPP/Boost/ProgramOptions/Simple|Simple command line argument parsing (ProgramOptions)]]&lt;br /&gt;
* [[CPP/Boost/ProgramOptions/MultipleArguments|Multiple command line argument parsing (ProgramOptions)]]&lt;br /&gt;
* [[CPP/Boost/ProgressBar|ProgressBar]]&lt;br /&gt;
* [[CPP/Boost/Threads|Threads]]&lt;br /&gt;
* [[CPP/Boost/ThreadsMember|Threads with member functions]]&lt;br /&gt;
* [[CPP/Boost/ThreadCommunication|ThreadCommunication]]&lt;br /&gt;
* [[CPP/Boost/Timer|Timer]]&lt;br /&gt;
* [[CPP/Boost/Signals/Basic|Signal/slot pattern]]&lt;br /&gt;
* [[CPP/Boost/Signals/Class|Signal/slot pattern with member functions]]&lt;br /&gt;
* [[CPP/Boost/Signals/ClassMember|Signal/slot pattern with member classes]]&lt;br /&gt;
* [[CPP/Boost/Signals/ClassMemberWithParameters|Signal/slot pattern with member classes which have parameters]]&lt;br /&gt;
* [[CPP/Boost/Signals2/Basic|Signals2: Signal/slot pattern with type safety]]&lt;br /&gt;
* [[CPP/Boost/Signals2/Parameters|Signals2: Signal/slot pattern with parameters type safety]]&lt;br /&gt;
&lt;br /&gt;
== Boost Graph Library (BGL) ==&lt;br /&gt;
=== Basics ===&lt;br /&gt;
* [[CPP/Boost/CreateGraph|Create a graph]] - This is the most fundamental process of using BGL - creating a graph. This example explains 3 methods of creating a graph, using adjacency_list directly, and also using the directed_graph and undirected_graph subclasses.&lt;br /&gt;
* [[CPP/Boost/BGL/IterateEdges|Iterate over all edges in the graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/EdgeExists|Check if an edge exists]] - If it does, you also get the edge_descriptor&lt;br /&gt;
* [[CPP/Boost/BGL/CopyAGraph|Copy a graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/Directed/Weighted|Access an edge]]&lt;br /&gt;
* [[CPP/Boost/RemoveVertex|Remove a vertex from a graph]]&lt;br /&gt;
* [[CPP/Boost/RemoveEdge|Remove an edge from a graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/EdgeProperties|Add properties to edges]]&lt;br /&gt;
* [[CPP/Boost/BGL/VertexProperties|Add properties to vertices]]&lt;br /&gt;
* [[CPP/Boost/BGL/BundledProperties|Bundled properties]]&lt;br /&gt;
* [[CPP/Boost/BGL/AdjacentVertices|Get a list of neighboring (adjacent) vertices]]&lt;br /&gt;
* [[CPP/Boost/BGL/DirectedGraph|Directed graphs only give access to out edges]]&lt;br /&gt;
* [[CPP/Boost/BGL/BidirectionalGraph|Bidirectional graphs give access to both in and out edges]]&lt;br /&gt;
* [[CPP/Boost/BGL/NumberOfNeighbors|Number of incoming, outgoing, and total edges]]&lt;br /&gt;
* [[CPP/Boost/BGL/BreadthFirstSearch|Breadth first search (BFS with a custom visitor)]]&lt;br /&gt;
* [[CPP/Boost/BGL/MakeBFSVisitor|Breadth first search with make_bfs_visitor]]&lt;br /&gt;
* [[CPP/Boost/BGL/DepthFirstSearch|Depth first search (DFS)]]&lt;br /&gt;
&lt;br /&gt;
=== I/O ===&lt;br /&gt;
* [[CPP/Boost/BGL/ReadGraph|Read a graph from a file]]&lt;br /&gt;
* [[CPP/Boost/BGL/WriteGraph|Write a graph to a file]]&lt;br /&gt;
* [[CPP/WishList/Boost/BGL/RelabelInputVertices|Relabel input vertices read from a dot file so they match the labels used in the file]]&lt;br /&gt;
&lt;br /&gt;
=== Algorithms ===&lt;br /&gt;
&lt;br /&gt;
* [[CPP/Boost/BGL/DijkstraDirected|Find the shortest path (Dijkstra) from a specified vertex to all other vertices in a directed graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/DijkstraUndirected|Find the shortest path (Dijkstra) from a specified vertex to all other vertices in an undirected graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/DijkstraComputePath|Find the shortest path (Dijkstra) from one specified vertex to another specified vertex in a graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/BetweennessCentralityClustering|Cluster a graph using betweenness centrality]]&lt;br /&gt;
&lt;br /&gt;
=== Visualization ===&lt;br /&gt;
&lt;br /&gt;
* [[CPP/Boost/BGL/InvisibleEdges|Create a graph with invisible edges]]&lt;br /&gt;
&lt;br /&gt;
=== Wish List ===&lt;br /&gt;
Examples in this section are either shells or something is wrong with them that must be fixed before they can graduate into real examples.&lt;br /&gt;
&lt;br /&gt;
== Boost (Generic) Geometry Library ==&lt;br /&gt;
* [[CPP/Boost/Geometry/DistanceBetweenPoints|Compute the distance between two points]]&lt;br /&gt;
* [[CPP/Boost/Geometry/PointInPolygon|Determine if a point is inside of a polygon (within() function)]]&lt;br /&gt;
* [[CPP/Boost/Geometry/Simplify|Simplify a polyline]]&lt;br /&gt;
&lt;br /&gt;
== Boost Math Library ==&lt;br /&gt;
=== Tools ===&lt;br /&gt;
* [[CPP/Boost/Math/Tools/TOMS748|TOMS748 root finding algorithm]]&lt;/div&gt;</summary>
		<author><name>Awallin</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/Boost</id>
		<title>Boost</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/Boost"/>
				<updated>2011-08-14T12:01:59Z</updated>
		
		<summary type="html">&lt;p&gt;Awallin: section for boost/math and link to toms748-example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The following examples are frequent use cases of parts of the Boost (http://www.boost.org/) library. Each example includes a CMakeLists.txt file so it can be easily compiled.&lt;br /&gt;
&lt;br /&gt;
* [[CPP/Boost/Bimap|Bidirectional (both ways) map]]&lt;br /&gt;
* [[CPP/Boost/Function|Glorified function pointers (function.hpp and bind.hpp)]]&lt;br /&gt;
* [[CPP/Boost/Histogram|Create a histogram (accumulator)]]&lt;br /&gt;
* [[CPP/Boost/Numeric/Matrix|Matrix]]&lt;br /&gt;
* [[CPP/Boost/Numeric/MultiArray|Multi dimensional array]]&lt;br /&gt;
* [[CPP/Boost/ProgramOptions/Simple|Simple command line argument parsing (ProgramOptions)]]&lt;br /&gt;
* [[CPP/Boost/ProgramOptions/MultipleArguments|Multiple command line argument parsing (ProgramOptions)]]&lt;br /&gt;
* [[CPP/Boost/ProgressBar|ProgressBar]]&lt;br /&gt;
* [[CPP/Boost/Threads|Threads]]&lt;br /&gt;
* [[CPP/Boost/ThreadsMember|Threads with member functions]]&lt;br /&gt;
* [[CPP/Boost/ThreadCommunication|ThreadCommunication]]&lt;br /&gt;
* [[CPP/Boost/Timer|Timer]]&lt;br /&gt;
* [[CPP/Boost/Signals/Basic|Signal/slot pattern]]&lt;br /&gt;
* [[CPP/Boost/Signals/Class|Signal/slot pattern with member functions]]&lt;br /&gt;
* [[CPP/Boost/Signals/ClassMember|Signal/slot pattern with member classes]]&lt;br /&gt;
* [[CPP/Boost/Signals/ClassMemberWithParameters|Signal/slot pattern with member classes which have parameters]]&lt;br /&gt;
* [[CPP/Boost/Signals2/Basic|Signals2: Signal/slot pattern with type safety]]&lt;br /&gt;
* [[CPP/Boost/Signals2/Parameters|Signals2: Signal/slot pattern with parameters type safety]]&lt;br /&gt;
&lt;br /&gt;
== Boost Graph Library (BGL) ==&lt;br /&gt;
=== Basics ===&lt;br /&gt;
* [[CPP/Boost/CreateGraph|Create a graph]] - This is the most fundamental process of using BGL - creating a graph. This example explains 3 methods of creating a graph, using adjacency_list directly, and also using the directed_graph and undirected_graph subclasses.&lt;br /&gt;
* [[CPP/Boost/BGL/IterateEdges|Iterate over all edges in the graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/EdgeExists|Check if an edge exists]] - If it does, you also get the edge_descriptor&lt;br /&gt;
* [[CPP/Boost/BGL/CopyAGraph|Copy a graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/Directed/Weighted|Access an edge]]&lt;br /&gt;
* [[CPP/Boost/RemoveVertex|Remove a vertex from a graph]]&lt;br /&gt;
* [[CPP/Boost/RemoveEdge|Remove an edge from a graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/EdgeProperties|Add properties to edges]]&lt;br /&gt;
* [[CPP/Boost/BGL/VertexProperties|Add properties to vertices]]&lt;br /&gt;
* [[CPP/Boost/BGL/BundledProperties|Bundled properties]]&lt;br /&gt;
* [[CPP/Boost/BGL/AdjacentVertices|Get a list of neighboring (adjacent) vertices]]&lt;br /&gt;
* [[CPP/Boost/BGL/DirectedGraph|Directed graphs only give access to out edges]]&lt;br /&gt;
* [[CPP/Boost/BGL/BidirectionalGraph|Bidirectional graphs give access to both in and out edges]]&lt;br /&gt;
* [[CPP/Boost/BGL/NumberOfNeighbors|Number of incoming, outgoing, and total edges]]&lt;br /&gt;
* [[CPP/Boost/BGL/BreadthFirstSearch|Breadth first search (BFS with a custom visitor)]]&lt;br /&gt;
* [[CPP/Boost/BGL/MakeBFSVisitor|Breadth first search with make_bfs_visitor]]&lt;br /&gt;
* [[CPP/Boost/BGL/DepthFirstSearch|Depth first search (DFS)]]&lt;br /&gt;
&lt;br /&gt;
=== I/O ===&lt;br /&gt;
* [[CPP/Boost/BGL/ReadGraph|Read a graph from a file]]&lt;br /&gt;
* [[CPP/Boost/BGL/WriteGraph|Write a graph to a file]]&lt;br /&gt;
* [[CPP/WishList/Boost/BGL/RelabelInputVertices|Relabel input vertices read from a dot file so they match the labels used in the file]]&lt;br /&gt;
&lt;br /&gt;
=== Algorithms ===&lt;br /&gt;
&lt;br /&gt;
* [[CPP/Boost/BGL/DijkstraDirected|Find the shortest path (Dijkstra) from a specified vertex to all other vertices in a directed graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/DijkstraUndirected|Find the shortest path (Dijkstra) from a specified vertex to all other vertices in an undirected graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/DijkstraComputePath|Find the shortest path (Dijkstra) from one specified vertex to another specified vertex in a graph]]&lt;br /&gt;
* [[CPP/Boost/BGL/BetweennessCentralityClustering|Cluster a graph using betweenness centrality]]&lt;br /&gt;
&lt;br /&gt;
=== Visualization ===&lt;br /&gt;
&lt;br /&gt;
* [[CPP/Boost/BGL/InvisibleEdges|Create a graph with invisible edges]]&lt;br /&gt;
&lt;br /&gt;
=== Wish List ===&lt;br /&gt;
Examples in this section are either shells or something is wrong with them that must be fixed before they can graduate into real examples.&lt;br /&gt;
&lt;br /&gt;
== Boost (Generic) Geometry Library ==&lt;br /&gt;
* [[CPP/Boost/Geometry/DistanceBetweenPoints|Compute the distance between two points]]&lt;br /&gt;
* [[CPP/Boost/Geometry/PointInPolygon|Determine if a point is inside of a polygon (within() function)]]&lt;br /&gt;
* [[CPP/Boost/Geometry/Simplify|Simplify a polyline]]&lt;br /&gt;
&lt;br /&gt;
== Boost Math Library ==&lt;br /&gt;
=== Tools ===&lt;br /&gt;
* [[CPP/Boost/Math/Tools/TOMS749|TOMS748 root finding algorithm]]&lt;/div&gt;</summary>
		<author><name>Awallin</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/Boost/BGL/CreateGraph</id>
		<title>Boost/BGL/CreateGraph</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/Boost/BGL/CreateGraph"/>
				<updated>2011-06-12T07:03:49Z</updated>
		
		<summary type="html">&lt;p&gt;Awallin: template params for adjacency_list&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==CreateGraph.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;                  // for std::cout&lt;br /&gt;
#include &amp;lt;utility&amp;gt;                   // for std::pair&lt;br /&gt;
#include &amp;lt;algorithm&amp;gt;                 // for std::for_each&lt;br /&gt;
#include &amp;lt;boost/graph/graph_traits.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/graph/adjacency_list.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
typedef boost::adjacency_list&amp;lt;boost::vecS, boost::vecS, boost::bidirectionalS&amp;gt; Graph;&lt;br /&gt;
&lt;br /&gt;
// up to 7 template parameters can be given, for example:&lt;br /&gt;
//  typedef boost::adjacency_list&amp;lt;     boost::listS,             // out-edges stored in a std::list&lt;br /&gt;
//                       boost::vecS,             // vertex set stored here&lt;br /&gt;
//                       boost::undirectedS,    // bidirectional graph.&lt;br /&gt;
//                       boost::no_property,              // vertex properties&lt;br /&gt;
//                       EdgeWeightProperty,       // edge properties&lt;br /&gt;
//                       boost::no_property,       // graph properties&lt;br /&gt;
//                       boost::listS              // edge storage&lt;br /&gt;
//                       &amp;gt; graph_t;&lt;br /&gt;
&lt;br /&gt;
int main(int,char*[])&lt;br /&gt;
{&lt;br /&gt;
  // Construct a graph&lt;br /&gt;
  Graph g(3); // 3 vertices&lt;br /&gt;
&lt;br /&gt;
  add_edge(0, 1, g);&lt;br /&gt;
  add_edge(1, 2, g);&lt;br /&gt;
&lt;br /&gt;
  // Get the vertices&lt;br /&gt;
  typedef boost::property_map&amp;lt;Graph, boost::vertex_index_t&amp;gt;::type IndexMap;&lt;br /&gt;
&lt;br /&gt;
  // &amp;quot;Ask a question&amp;quot; of a graph. The IndexMap is the solution set.&lt;br /&gt;
  IndexMap index = get(boost::vertex_index, g);&lt;br /&gt;
  &lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;vertices = &amp;quot;;&lt;br /&gt;
  typedef boost::graph_traits&amp;lt;Graph&amp;gt;::vertex_iterator vertex_iter;&lt;br /&gt;
  std::pair&amp;lt;vertex_iter, vertex_iter&amp;gt; vertexPair;&lt;br /&gt;
  // The call to vertices(g) sets vp to (0, numberOfElements)&lt;br /&gt;
  // The loop, therefore, starts at 0, and increments the 'first' of the vertexPair&lt;br /&gt;
  // until it equals the 'second', which again is the numberOfElements.&lt;br /&gt;
  for (vertexPair = vertices(g); vertexPair.first != vertexPair.second; ++vertexPair.first)&lt;br /&gt;
  {&lt;br /&gt;
    // You can see what is going on with this:&lt;br /&gt;
	//std::cout &amp;lt;&amp;lt; &amp;quot;first: &amp;quot; &amp;lt;&amp;lt; index[*vertexPair.first] &amp;lt;&amp;lt;  &amp;quot; second: &amp;quot; &amp;lt;&amp;lt; index[*vp.second] &amp;lt;&amp;lt; std::endl; // the vertex iterator&lt;br /&gt;
&lt;br /&gt;
	// Or just output the vertex ids&lt;br /&gt;
	std::cout &amp;lt;&amp;lt; index[*vertexPair.first] &amp;lt;&amp;lt;  &amp;quot; &amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;edges = &amp;quot;;&lt;br /&gt;
  typedef boost::graph_traits&amp;lt;Graph&amp;gt;::edge_iterator edge_iter;&lt;br /&gt;
  std::pair&amp;lt;edge_iter, edge_iter&amp;gt; edgePair;&lt;br /&gt;
  for(edgePair = edges(g); edgePair.first != edgePair.second; ++edgePair.first)&lt;br /&gt;
  {&lt;br /&gt;
      std::cout &amp;lt;&amp;lt; &amp;quot;(&amp;quot; &amp;lt;&amp;lt; index[source(*edgePair.first, g)]&lt;br /&gt;
              &amp;lt;&amp;lt; &amp;quot;,&amp;quot; &amp;lt;&amp;lt; index[target(*edgePair.first, g)] &amp;lt;&amp;lt; &amp;quot;) &amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==CMakeLists.txt==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
cmake_minimum_required(VERSION 2.6)&lt;br /&gt;
&lt;br /&gt;
Project(ConstructGraph)&lt;br /&gt;
&lt;br /&gt;
set(Boost_USE_MULTITHREADED ON)&lt;br /&gt;
FIND_PACKAGE(Boost 1.38 COMPONENTS required)&lt;br /&gt;
&lt;br /&gt;
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${Boost_INCLUDE_DIRS})&lt;br /&gt;
LINK_DIRECTORIES(${LINK_DIRECTORIES} ${Boost_LIBRARY_DIRS})&lt;br /&gt;
&lt;br /&gt;
ADD_EXECUTABLE(ConstructGraph ConstructGraph.cpp)&lt;br /&gt;
target_link_libraries(ConstructGraph)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Awallin</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/Boost/BGL/BundledProperties</id>
		<title>Boost/BGL/BundledProperties</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/Boost/BGL/BundledProperties"/>
				<updated>2011-06-11T21:53:28Z</updated>
		
		<summary type="html">&lt;p&gt;Awallin: with bundled properties, using operator[] is more elegant (?)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==BundledProperties.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/graph/adjacency_list.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Create a struct to hold several properties&lt;br /&gt;
struct MyProperty&lt;br /&gt;
{&lt;br /&gt;
  int MyIntProperty;&lt;br /&gt;
  std::string MyStringProperty;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
// Define the type of the graph - this specifies a bundled property for vertices&lt;br /&gt;
typedef boost::adjacency_list&amp;lt;boost::vecS, boost::vecS, boost::undirectedS, MyProperty&amp;gt; Graph;&lt;br /&gt;
&lt;br /&gt;
// Define the type of the graph - this specifies a bundled property for edges&lt;br /&gt;
//typedef boost::adjacency_list&amp;lt;boost::vecS, boost::vecS, boost::undirectedS, boost::no_property, MyProperty&amp;gt; Graph;&lt;br /&gt;
&lt;br /&gt;
int main(int,char*[])&lt;br /&gt;
{&lt;br /&gt;
  // Create a graph object&lt;br /&gt;
  Graph g(2);&lt;br /&gt;
&lt;br /&gt;
  boost::property_map&amp;lt;Graph, int MyProperty::*&amp;gt;::type MyIntPropertyMap = boost::get(&amp;amp;MyProperty::MyIntProperty, g);&lt;br /&gt;
  boost::put(MyIntPropertyMap, 0, 5);&lt;br /&gt;
  boost::put(MyIntPropertyMap, 1, 10);&lt;br /&gt;
&lt;br /&gt;
  boost::property_map&amp;lt;Graph, std::string MyProperty::*&amp;gt;::type MyStringPropertyMap = boost::get(&amp;amp;MyProperty::MyStringProperty, g);&lt;br /&gt;
  boost::put(MyStringPropertyMap, 0, &amp;quot;TestName0&amp;quot;);&lt;br /&gt;
  boost::put(MyStringPropertyMap, 1, &amp;quot;TestName1&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
  // NOTE: the above code is equivalent to the slightly more elegant:&lt;br /&gt;
  // g[0].MyIntProperty = 5&lt;br /&gt;
  // g[1].MyIntProperty = 10&lt;br /&gt;
  // g[0].MyStringProperty = &amp;quot;TestName0&amp;quot;&lt;br /&gt;
  // g[1].MyStringProperty = &amp;quot;TestName1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  typedef boost::property_map&amp;lt;Graph, boost::vertex_index_t&amp;gt;::type IndexMap;&lt;br /&gt;
  IndexMap index = get(boost::vertex_index, g);&lt;br /&gt;
&lt;br /&gt;
  typedef boost::graph_traits&amp;lt;Graph&amp;gt;::vertex_iterator vertex_iter;&lt;br /&gt;
  std::pair&amp;lt;vertex_iter, vertex_iter&amp;gt; vertexPair;&lt;br /&gt;
  for (vertexPair = vertices(g); vertexPair.first != vertexPair.second; ++vertexPair.first)&lt;br /&gt;
    {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; index[*vertexPair.first] &amp;lt;&amp;lt;  &amp;quot; : &amp;quot; &amp;lt;&amp;lt; MyIntPropertyMap[*vertexPair.first] &amp;lt;&amp;lt; &amp;quot; : &amp;quot; &amp;lt;&amp;lt; MyStringPropertyMap[*vertexPair.first] &amp;lt;&amp;lt;  std::endl;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==CMakeLists.txt==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
cmake_minimum_required(VERSION 2.6)&lt;br /&gt;
&lt;br /&gt;
Project(BundledProperties)&lt;br /&gt;
&lt;br /&gt;
set(Boost_USE_MULTITHREADED ON)&lt;br /&gt;
FIND_PACKAGE(Boost 1.38 COMPONENTS required)&lt;br /&gt;
&lt;br /&gt;
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${Boost_INCLUDE_DIRS})&lt;br /&gt;
LINK_DIRECTORIES(${LINK_DIRECTORIES} ${Boost_LIBRARY_DIRS})&lt;br /&gt;
&lt;br /&gt;
ADD_EXECUTABLE(BundledProperties BundledProperties.cpp)&lt;br /&gt;
target_link_libraries(BundledProperties)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Awallin</name></author>	</entry>

	<entry>
		<id>http://www.programmingexamples.net/wiki/Boost/BGL/Directed/Weighted</id>
		<title>Boost/BGL/Directed/Weighted</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/wiki/Boost/BGL/Directed/Weighted"/>
				<updated>2011-06-11T21:49:06Z</updated>
		
		<summary type="html">&lt;p&gt;Awallin: 3rd method using boost::get&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Edge.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/graph/graph_traits.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/graph/directed_graph.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
typedef boost::property&amp;lt;boost::edge_weight_t, float&amp;gt; EdgeWeightProperty;&lt;br /&gt;
&lt;br /&gt;
typedef boost::directed_graph&amp;lt;boost::no_property, EdgeWeightProperty&amp;gt; Graph;&lt;br /&gt;
&lt;br /&gt;
int main(int,char*[])&lt;br /&gt;
{&lt;br /&gt;
  // Create a graph object&lt;br /&gt;
  Graph g;&lt;br /&gt;
  &lt;br /&gt;
  // Add vertices to the graph&lt;br /&gt;
  Graph::vertex_descriptor v0 = g.add_vertex();&lt;br /&gt;
  Graph::vertex_descriptor v1 = g.add_vertex();&lt;br /&gt;
  Graph::vertex_descriptor v2 = g.add_vertex();&lt;br /&gt;
&lt;br /&gt;
  // Create weighted edges&lt;br /&gt;
  EdgeWeightProperty weight0 = 5;&lt;br /&gt;
  boost::add_edge(v0,v1,weight0,g);&lt;br /&gt;
  &lt;br /&gt;
  EdgeWeightProperty weight1 = 6;&lt;br /&gt;
  boost::add_edge(v1,v2,weight1,g);&lt;br /&gt;
&lt;br /&gt;
  // Retrieve the weight of an edge (method 1, works)&lt;br /&gt;
  {&lt;br /&gt;
  typedef boost::property_map&amp;lt;Graph, boost::edge_weight_t&amp;gt;::type EdgeWeightMap;&lt;br /&gt;
  EdgeWeightMap edgeWeightMap = get(boost::edge_weight, g);&lt;br /&gt;
&lt;br /&gt;
  std::pair&amp;lt;Graph::edge_descriptor, bool&amp;gt; edgePair = boost::edge(v0, v1, g);&lt;br /&gt;
  Graph::edge_descriptor edge = edgePair.first;&lt;br /&gt;
&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Edge (&amp;quot; &amp;lt;&amp;lt; v0 &amp;lt;&amp;lt; &amp;quot;, &amp;quot; &amp;lt;&amp;lt; v1 &amp;lt;&amp;lt; &amp;quot;) has weight &amp;quot; &amp;lt;&amp;lt; edgeWeightMap[edge] &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // Retrieve the weight of an edge (method 2, doesn't work)&lt;br /&gt;
  {&lt;br /&gt;
  std::pair&amp;lt;Graph::edge_descriptor, bool&amp;gt; edgePair = boost::edge(v0, v1, g);&lt;br /&gt;
  Graph::edge_descriptor edge = edgePair.first;&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Edge (&amp;quot; &amp;lt;&amp;lt; v0 &amp;lt;&amp;lt; &amp;quot;, &amp;quot; &amp;lt;&amp;lt; v1 &amp;lt;&amp;lt; &amp;quot;) has weight &amp;quot; &amp;lt;&amp;lt; g[edge]-&amp;gt;edge_weight &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  // method 3&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; std::cout &amp;lt;&amp;lt; &amp;quot;Edge (&amp;quot; &amp;lt;&amp;lt; v0 &amp;lt;&amp;lt; &amp;quot;, &amp;quot; &amp;lt;&amp;lt; v1 &amp;lt;&amp;lt; &amp;quot;) has weight &amp;quot; &amp;lt;&amp;lt; boost::get( boost::edge_weight, g, edge ) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==CMakeLists.txt==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
cmake_minimum_required(VERSION 2.6)&lt;br /&gt;
&lt;br /&gt;
Project(Weighted)&lt;br /&gt;
&lt;br /&gt;
set(Boost_USE_MULTITHREADED ON)&lt;br /&gt;
FIND_PACKAGE(Boost 1.38 COMPONENTS required)&lt;br /&gt;
&lt;br /&gt;
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${Boost_INCLUDE_DIRS})&lt;br /&gt;
LINK_DIRECTORIES(${LINK_DIRECTORIES} ${Boost_LIBRARY_DIRS})&lt;br /&gt;
&lt;br /&gt;
ADD_EXECUTABLE(Weighted Weighted.cpp)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Awallin</name></author>	</entry>

	</feed>