File: random.html

package info (click to toggle)
boost1.35 1.35.0-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 203,856 kB
  • ctags: 337,867
  • sloc: cpp: 938,683; xml: 56,847; ansic: 41,589; python: 18,999; sh: 11,566; makefile: 664; perl: 494; yacc: 456; asm: 353; csh: 6
file content (117 lines) | stat: -rw-r--r-- 3,713 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<html>
<!--
  -- Copyright (c) 2003 Vladimir Prus
  --
  -- 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: random</title>

<body BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b" 
        ALINK="#ff0000"> 
<IMG SRC="../../../boost.png" 
     ALT="C++ Boost" width="277" height="86"> 

<br>

The header <tt>&lt;boost/graph/random&gt;</tt> provides routines to create
random graph, select random vertices and edges, and randomize properties.

<h1>Synopsis</h1>

<pre>

  template &lt;class Graph, class RandomNumGen&gt;
  typename graph_traits&lt;Graph&gt;::vertex_descriptor
  random_vertex(Graph&amp; g, RandomNumGen&amp; gen);

  template &lt;class Graph, class RandomNumGen&gt;
  typename graph_traits&lt;Graph&gt;::edge_descriptor
  random_edge(Graph&amp; g, RandomNumGen&amp; gen);

  template &lt;typename MutableGraph, class RandNumGen&gt;
  void generate_random_graph
    (MutableGraph&amp; g, 
     typename graph_traits&lt;MutableGraph&gt;::vertices_size_type V,
     typename graph_traits&lt;MutableGraph&gt;::vertices_size_type E,
     RandNumGen&amp; gen,
     bool self_edges = false);

  template&lt;class Property, class G, class RandomGenerator&gt;
    void randomize_property(G&amp; g, RandomGenerator rg);

</pre>

<h1>Description</h1>

<h2 id="random_vertex">random_vertex</h2>

<pre>
  template &lt;class Graph, class RandomNumGen&gt;
  typename graph_traits&lt;Graph&gt;::vertex_descriptor
  random_vertex(Graph&amp; g, RandomNumGen&amp; gen);
</pre>

<p><b>Effects:</b> Selects a random vertex in a graph and returns it.
<p><b>Preconditions:</b> <tt>num_vertices(g) != 0</tt>
<p><b>Complexity:</b> <tt>O(num_vertices(g))</tt>

<h2 id="random_edge">random_edge</h2>

<pre>
  template &lt;class Graph, class RandomNumGen&gt;
  typename graph_traits&lt;Graph&gt;::edge_descriptor
  random_edge(Graph&amp; g, RandomNumGen&amp; gen);
</pre>

<p><b>Effects:</b> Selects a random edge in a graph and returns it.
<p><b>Preconditions:</b> <tt>num_edges(g) != 0</tt>
<p><b>Complexity:</b> <tt>O(num_edges(g))</tt>

<h2 id="generate_random_graph">generate_random_graph</h2>

<pre>
  template &lt;typename MutableGraph, class RandNumGen&gt;
  void generate_random_graph
    (MutableGraph&amp; g, 
     typename graph_traits&lt;MutableGraph&gt;::vertices_size_type V,
     typename graph_traits&lt;MutableGraph&gt;::vertices_size_type E,
     RandNumGen&amp; gen,
     bool allow_parallel = true,
     bool self_edges = false);
</pre>

<p><b>Effects:</b> Adds <tt>V</tt> vertices and <tt>E</tt> edges, to
<tt>g</tt>. Source and target vertices of each edge are randomly choosen. If
<tt>self_edges</tt> is false, then no edge will have the same source and
targets.
<p><b>Precondition:</b> <tt>num_vertices(g) == 0</tt>
<p><b>Compleixity:</b> <tt>O(V*E)</tt>

<h2 id="randomize_property">randomize_property</h2>

<pre>
  template&lt;class Property, class G, class RandomGenerator&gt;
    void randomize_property(G&amp; g, RandomGenerator&amp; rg);
</pre>

<p><b>Effects:</b> Sets the random value of property on either all vertices, or
all edges, depending on property kind.
<p><b>Complexity:</b> <tt>O(V)</tt> or <tt>O(E)</tt>, depending on property
kind.

<hr>

<p class="revision">Last modified: Feb 05, 2003</p>

<p>&copy; Copyright Vladimir Prus 2003. Permission to copy, use, modify,
sell and distribute this document is granted provided this copyright
notice appears in all copies. This document is provided ``as is'' without
express or implied warranty, and with no claim as to its suitability for
any purpose.</p>

</body>

</html>