Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/graph/doc/random.html @ 14

Last change on this file since 14 was 12, checked in by landauf, 17 years ago

added boost

File size: 3.4 KB
Line 
1<html>
2<head>
3<title>Boost Graph Library: random</title>
4
5<body BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b" 
6        ALINK="#ff0000"> 
7<IMG SRC="../../../boost.png" 
8     ALT="C++ Boost" width="277" height="86"> 
9
10<br>
11
12The header <tt>&lt;boost/graph/random&gt;</tt> provides routines to create
13random graph, select random vertices and edges, and randomize properties.
14
15<h1>Synopsis</h1>
16
17<pre>
18
19  template &lt;class Graph, class RandomNumGen&gt;
20  typename graph_traits&lt;Graph&gt;::vertex_descriptor
21  random_vertex(Graph&amp; g, RandomNumGen&amp; gen);
22
23  template &lt;class Graph, class RandomNumGen&gt;
24  typename graph_traits&lt;Graph&gt;::edge_descriptor
25  random_edge(Graph&amp; g, RandomNumGen&amp; gen);
26
27  template &lt;typename MutableGraph, class RandNumGen&gt;
28  void generate_random_graph
29    (MutableGraph&amp; g,
30     typename graph_traits&lt;MutableGraph&gt;::vertices_size_type V,
31     typename graph_traits&lt;MutableGraph&gt;::vertices_size_type E,
32     RandNumGen&amp; gen,
33     bool self_edges = false);
34
35  template&lt;class Property, class G, class RandomGenerator&gt;
36    void randomize_property(G&amp; g, RandomGenerator rg);
37
38</pre>
39
40<h1>Description</h1>
41
42<h2 id="random_vertex">random_vertex</h2>
43
44<pre>
45  template &lt;class Graph, class RandomNumGen&gt;
46  typename graph_traits&lt;Graph&gt;::vertex_descriptor
47  random_vertex(Graph&amp; g, RandomNumGen&amp; gen);
48</pre>
49
50<p><b>Effects:</b> Selects a random vertex in a graph and returns it.
51<p><b>Preconditions:</b> <tt>num_vertices(g) != 0</tt>
52<p><b>Complexity:</b> <tt>O(num_vertices(g))</tt>
53
54<h2 id="random_edge">random_edge</h2>
55
56<pre>
57  template &lt;class Graph, class RandomNumGen&gt;
58  typename graph_traits&lt;Graph&gt;::edge_descriptor
59  random_edge(Graph&amp; g, RandomNumGen&amp; gen);
60</pre>
61
62<p><b>Effects:</b> Selects a random edge in a graph and returns it.
63<p><b>Preconditions:</b> <tt>num_edges(g) != 0</tt>
64<p><b>Complexity:</b> <tt>O(num_edges(g))</tt>
65
66<h2 id="generate_random_graph">generate_random_graph</h2>
67
68<pre>
69  template &lt;typename MutableGraph, class RandNumGen&gt;
70  void generate_random_graph
71    (MutableGraph&amp; g,
72     typename graph_traits&lt;MutableGraph&gt;::vertices_size_type V,
73     typename graph_traits&lt;MutableGraph&gt;::vertices_size_type E,
74     RandNumGen&amp; gen,
75     bool allow_parallel = true,
76     bool self_edges = false);
77</pre>
78
79<p><b>Effects:</b> Adds <tt>V</tt> vertices and <tt>E</tt> edges, to
80<tt>g</tt>. Source and target vertices of each edge are randomly choosen. If
81<tt>self_edges</tt> is false, then no edge will have the same source and
82targets.
83<p><b>Precondition:</b> <tt>num_vertices(g) == 0</tt>
84<p><b>Compleixity:</b> <tt>O(V*E)</tt>
85
86<h2 id="randomize_property">randomize_property</h2>
87
88<pre>
89  template&lt;class Property, class G, class RandomGenerator&gt;
90    void randomize_property(G&amp; g, RandomGenerator&amp; rg);
91</pre>
92
93<p><b>Effects:</b> Sets the random value of property on either all vertices, or
94all edges, depending on property kind.
95<p><b>Complexity:</b> <tt>O(V)</tt> or <tt>O(E)</tt>, depending on property
96kind.
97
98<hr>
99
100<p class="revision">Last modified: Feb 05, 2003</p>
101
102<p>&copy; Copyright Vladimir Prus 2003. Permission to copy, use, modify,
103sell and distribute this document is granted provided this copyright
104notice appears in all copies. This document is provided ``as is'' without
105express or implied warranty, and with no claim as to its suitability for
106any purpose.</p>
107
108</body>
109
110</html>
Note: See TracBrowser for help on using the repository browser.