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 | |
---|
12 | The header <tt><boost/graph/random></tt> provides routines to create |
---|
13 | random graph, select random vertices and edges, and randomize properties. |
---|
14 | |
---|
15 | <h1>Synopsis</h1> |
---|
16 | |
---|
17 | <pre> |
---|
18 | |
---|
19 | template <class Graph, class RandomNumGen> |
---|
20 | typename graph_traits<Graph>::vertex_descriptor |
---|
21 | random_vertex(Graph& g, RandomNumGen& gen); |
---|
22 | |
---|
23 | template <class Graph, class RandomNumGen> |
---|
24 | typename graph_traits<Graph>::edge_descriptor |
---|
25 | random_edge(Graph& g, RandomNumGen& gen); |
---|
26 | |
---|
27 | template <typename MutableGraph, class RandNumGen> |
---|
28 | void generate_random_graph |
---|
29 | (MutableGraph& g, |
---|
30 | typename graph_traits<MutableGraph>::vertices_size_type V, |
---|
31 | typename graph_traits<MutableGraph>::vertices_size_type E, |
---|
32 | RandNumGen& gen, |
---|
33 | bool self_edges = false); |
---|
34 | |
---|
35 | template<class Property, class G, class RandomGenerator> |
---|
36 | void randomize_property(G& 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 <class Graph, class RandomNumGen> |
---|
46 | typename graph_traits<Graph>::vertex_descriptor |
---|
47 | random_vertex(Graph& g, RandomNumGen& 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 <class Graph, class RandomNumGen> |
---|
58 | typename graph_traits<Graph>::edge_descriptor |
---|
59 | random_edge(Graph& g, RandomNumGen& 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 <typename MutableGraph, class RandNumGen> |
---|
70 | void generate_random_graph |
---|
71 | (MutableGraph& g, |
---|
72 | typename graph_traits<MutableGraph>::vertices_size_type V, |
---|
73 | typename graph_traits<MutableGraph>::vertices_size_type E, |
---|
74 | RandNumGen& 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 |
---|
82 | targets. |
---|
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<class Property, class G, class RandomGenerator> |
---|
90 | void randomize_property(G& g, RandomGenerator& rg); |
---|
91 | </pre> |
---|
92 | |
---|
93 | <p><b>Effects:</b> Sets the random value of property on either all vertices, or |
---|
94 | all edges, depending on property kind. |
---|
95 | <p><b>Complexity:</b> <tt>O(V)</tt> or <tt>O(E)</tt>, depending on property |
---|
96 | kind. |
---|
97 | |
---|
98 | <hr> |
---|
99 | |
---|
100 | <p class="revision">Last modified: Feb 05, 2003</p> |
---|
101 | |
---|
102 | <p>© Copyright Vladimir Prus 2003. Permission to copy, use, modify, |
---|
103 | sell and distribute this document is granted provided this copyright |
---|
104 | notice appears in all copies. This document is provided ``as is'' without |
---|
105 | express or implied warranty, and with no claim as to its suitability for |
---|
106 | any purpose.</p> |
---|
107 | |
---|
108 | </body> |
---|
109 | |
---|
110 | </html> |
---|