]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <HTML> |
2 | <!-- | |
3 | Copyright (c) Jeremy Siek 2000 | |
4 | ||
5 | Distributed under the Boost Software License, Version 1.0. | |
6 | (See accompanying file LICENSE_1_0.txt or copy at | |
7 | http://www.boost.org/LICENSE_1_0.txt) | |
8 | --> | |
9 | <Head> | |
10 | <Title>Boost Graph Library: Transpose Graph</Title> | |
11 | <BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b" | |
12 | ALINK="#ff0000"> | |
13 | <IMG SRC="../../../boost.png" | |
14 | ALT="C++ Boost" width="277" height="86"> | |
15 | ||
16 | <BR Clear> | |
17 | ||
18 | <H1><TT>transpose_graph</TT></H1> | |
19 | ||
20 | <PRE> | |
21 | template <class <a href="./VertexListGraph.html">VertexListGraph</a>, class <a href="./MutableGraph.html">MutableGraph</a>> | |
22 | void transpose_graph(const VertexListGraph& G, MutableGraph& G_T, | |
23 | const bgl_named_params<P, T, R>& params = <i>all defaults</i>) | |
24 | </PRE> | |
25 | ||
26 | <P> | |
27 | This function computes the transpose of a directed graph. The | |
28 | transpose of a directed graph <i>G = (V, E)</i>is the graph | |
29 | <i>G<sup>T</sup> = (V, E<sup>T</sup>)</i> , where <i>E<sup>T</sup> = | |
30 | {(v, u) in V x V: (u, v) in E}</i> . i.e., <i>G<sup>T</sup></i> is | |
31 | <i>G</i> with all its edges reversed. Graph <TT>G_T</TT> passed into | |
32 | the algorithm must have no vertices and | |
33 | no edges. The vertices and edges will be added by <tt>transpose_graph()</tt> by | |
34 | calling <tt>add_vertex</tt> and <tt>add_edge</tt> as follows for each edge | |
35 | <i>(u,v)</i> in <tt>G</tt>. | |
36 | ||
37 | <H3>Example</H3> | |
38 | ||
39 | Here's an example of transposing a graph: | |
40 | <a href="../example/transpose-example.cpp"><tt>example/transpose-example.cpp</tt></a>. | |
41 | ||
42 | <H3>Where Defined</H3> | |
43 | ||
44 | <P> | |
45 | <a href="../../../boost/graph/transpose_graph.hpp"><TT>boost/graph/transpose_graph.hpp</TT></a> | |
46 | ||
47 | <P> | |
48 | ||
49 | <H3>Parameters</H3> | |
50 | ||
51 | IN: <tt>const VertexListGraph& G</tt> | |
52 | <blockquote> | |
53 | A directed graph. The graph type must be a model of <a href="./VertexListGraph.html">Vertex List Graph</a>. | |
54 | </blockquote> | |
55 | ||
56 | OUT: <tt>const MutableGraph& G_T</tt> | |
57 | <blockquote> | |
58 | The transposed graph. The graph type must be a model of <a | |
59 | href="./MutableGraph.html">Mutable Graph</a>. | |
60 | </blockquote> | |
61 | ||
62 | <h3>Named Parameters</h3> | |
63 | ||
64 | IN: <tt>vertex_copy(VertexCopier vc)</tt> | |
65 | <blockquote> | |
66 | This is a <a href="http://www.sgi.com/tech/stl/BinaryFunction.html">Binary Function</a> that copies the properties of a vertex in the original graph | |
67 | into the corresponding vertex in the copy.<br> | |
68 | ||
69 | <b>Default:</b> <tt>vertex_copier<VertexListGraph, MutableGraph></tt> | |
70 | which uses the property tag <tt>vertex_all</tt> to access a property | |
71 | map from the graph. | |
72 | </blockquote> | |
73 | ||
74 | IN: <tt>edge_copy(EdgeCopier ec)</tt> | |
75 | <blockquote> | |
76 | This is a <a href="http://www.sgi.com/tech/stl/BinaryFunction.html">Binary Function</a> that copies the properties of an edge in the original graph | |
77 | into the corresponding edge in the copy.<br> | |
78 | ||
79 | <b>Default:</b> <tt>edge_copier<VertexListGraph, MutableGraph></tt> | |
80 | which uses the property tag <tt>edge_all</tt> to access a property | |
81 | map from the graph. | |
82 | </blockquote> | |
83 | ||
84 | IN: <tt>vertex_index_map(VertexIndexMap i_map)</tt> | |
85 | <blockquote> | |
86 | The vertex index map type must be a model of <a | |
87 | href="../../property_map/doc/ReadablePropertyMap.html">Readable Property | |
88 | Map</a> and must map the vertex descriptors of <tt>G</tt> to the | |
89 | integers from 0 to <tt>num_vertices(G)</tt>.<br> | |
90 | ||
91 | <b>Default:</b> <tt>get(vertex_index, G)</tt> | |
92 | Note: if you use this default, make sure your graph has | |
93 | an internal <tt>vertex_index</tt> property. For example, | |
94 | <tt>adjacency_list</tt> with <tt>VertexList=listS</tt> does | |
95 | not have an internal <tt>vertex_index</tt> property. | |
96 | </blockquote> | |
97 | ||
98 | ||
99 | UTIL/OUT: <tt>orig_to_copy(Orig2CopyMap c)</tt> | |
100 | <blockquote> | |
101 | This maps vertices in the original graph to vertices in the copy. | |
102 | ||
103 | <b>Default:</b> an <a | |
104 | href="../../property_map/doc/iterator_property_map.html"> | |
105 | </tt>iterator_property_map</tt></a> created from a | |
106 | <tt>std::vector</tt> of the output graph's vertex descriptor type of size | |
107 | <tt>num_vertices(g)</tt> and using the <tt>i_map</tt> for the index | |
108 | map. | |
109 | </blockquote> | |
110 | ||
111 | <H3>Complexity</H3> | |
112 | ||
113 | <P> | |
114 | The time complexity is <i>O(V + E)</i>. | |
115 | ||
116 | ||
117 | ||
118 | <br> | |
119 | <HR> | |
120 | <TABLE> | |
121 | <TR valign=top> | |
122 | <TD nowrap>Copyright © 2000-2001</TD><TD> | |
123 | <A HREF="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>) | |
124 | </TD></TR></TABLE> | |
125 | ||
126 | </BODY> | |
127 | </HTML> |