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><boost/graph/random></tt> provides routines to create
random graph, select random vertices and edges, and randomize properties.
<h1>Synopsis</h1>
<pre>
template <class Graph, class RandomNumGen>
typename graph_traits<Graph>::vertex_descriptor
random_vertex(Graph& g, RandomNumGen& gen);
template <class Graph, class RandomNumGen>
typename graph_traits<Graph>::edge_descriptor
random_edge(Graph& g, RandomNumGen& gen);
template <typename MutableGraph, class RandNumGen>
void generate_random_graph
(MutableGraph& g,
typename graph_traits<MutableGraph>::vertices_size_type V,
typename graph_traits<MutableGraph>::vertices_size_type E,
RandNumGen& gen,
bool self_edges = false);
template<class Property, class G, class RandomGenerator>
void randomize_property(G& g, RandomGenerator rg);
</pre>
<h1>Description</h1>
<h2 id="random_vertex">random_vertex</h2>
<pre>
template <class Graph, class RandomNumGen>
typename graph_traits<Graph>::vertex_descriptor
random_vertex(Graph& g, RandomNumGen& 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 <class Graph, class RandomNumGen>
typename graph_traits<Graph>::edge_descriptor
random_edge(Graph& g, RandomNumGen& 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 <typename MutableGraph, class RandNumGen>
void generate_random_graph
(MutableGraph& g,
typename graph_traits<MutableGraph>::vertices_size_type V,
typename graph_traits<MutableGraph>::vertices_size_type E,
RandNumGen& 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<class Property, class G, class RandomGenerator>
void randomize_property(G& g, RandomGenerator& 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>© 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>
|