File: IteratorConstructibleGraph.html

package info (click to toggle)
boost 1.27.0-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 19,908 kB
  • ctags: 26,546
  • sloc: cpp: 122,225; ansic: 10,956; python: 4,412; sh: 855; yacc: 803; makefile: 257; perl: 165; lex: 90; csh: 6
file content (165 lines) | stat: -rw-r--r-- 4,823 bytes parent folder | download
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<HTML>
<!--
  -- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
  --
  -- Permission to use, copy, modify, distribute and sell this software
  -- and its documentation for any purpose is hereby granted without fee,
  -- provided that the above copyright notice appears in all copies and
  -- that both that copyright notice and this permission notice appear
  -- in supporting documentation.  We make no
  -- representations about the suitability of this software for any
  -- purpose.  It is provided "as is" without express or implied warranty.
  -->
<Head>
<Title>IteratorConstructibleGraph</Title>
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b" 
        ALINK="#ff0000"> 
<IMG SRC="../../../c++boost.gif" 
     ALT="C++ Boost" width="277" height="86"> 

<BR Clear>

<H1><A NAME="concept:IteratorConstructibleGraph"></A>
IteratorConstructibleGraph
</H1>

The IteratorConstructibleGraph concept describes the interface for
graph types that can be constructed using a kind of edge iterator. The
edge iterator can be any <a
href="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>
that dereferences to a pair of integers <i>(i,j)</i>, which represent
an edge that should be in the graph. The two integers <i>i</i> and
<i>j</i> represent vertices where <i>0 <= i < |V|</i> and <i>0 <= j <
|V|</i>.  The edge iterator's value type should be
<tt>std::pair&lt;T,T&gt;</tt> (or at least be a structure that has
members <tt>first</tt> and <tt>second</tt>) and the value type
<tt>T</tt> of the pair must be convertible to the
<tt>vertices_size_type</tt> of the graph (an integer).

There are two valid expressions required by this concept, both of
which are constructors. The first creates a graph object from a
first/last iterator range. The second constructor also takes a
first/last iterator range and in addition requires the number of
vertices and number of edges. For some graph and edge iterator types
the second constructor can be more efficient than the first.

<h3>Example</h3>

The following exampe creates two graph objects from an array of edges
(vertex pairs). The type <tt>Edge*</tt> satisfies the requirements for
an <a
href="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>
and can therefore be used to construct a graph.

<pre>
  typedef ... IteratorConstructibleGraph;
  typedef boost::graph_traits<IteratorConstructibleGraph> Traits;

  typedef std::pair<Traits::vertices_size_type, 
    Traits::vertices_size_type> Edge;
  Edge edge_array[] =
    { Edge(0,1), Edge(0,2), Edge(0,3), Edge(0,4), Edge(0,5),
      Edge(1, 2), Edge(1,5), Edge(1,3),
      Edge(2, 4), Edge(2,5),
      Edge(3, 2), 
      Edge(4, 3), Edge(4,1),
      Edge(5, 4) };
  Edge* first = edge_array,
    last = edge_array + sizeof(edge_array)/sizeof(Edge);

  IteratorConstructibleGraph G1(first, last);
  // do something with G1 ...
  
  Traits::vertices_size_type size_V = 6;
  Traits::edges_size_type size_E = sizeof(edge_array)/sizeof(Edge);
  IteratorConstructibleGraph G2(first, last, size_V, size_E);
  // do something with G2 ...
</pre>

<h3>Refinement of</h3>

<a href="Graph.html">Graph</a>

<h3>Notation</h3>

<Table>
<tr>
<td><tt>G</tt></td>
<td>is a graph type that models IteratorConstructibleGraph.</td>
<tr>

<tr>
<td><tt>g</tt></td>
<td>is an object of type <tt>G</tt>.</td>
</tr>

<tr>
<td><tt>first, last</tt></td>
<td>are edge iterators (see above).</td>
</tr>

<tr>
<td><tt>Tr</tt></td>
<td>is an object of type <tt>graph_traits&lt;G&gt;</tt>.</td>
</tr>

<tr>
<td><tt>n_vertices</tt></td>
<td>is an object of type <tt>Tr::vertices_size_type</tt>.</td>
</tr>

<tr>
<td><tt>n_edges</tt></td>
<td>is an object of type <tt>Tr::edges_size_type</tt>.</td>
</tr>

</Table>


<h3>Valid Expressions</h3>

<Table border>

<tr>
<td>
<pre>G g(first, last);</pre>
Construct graph object <tt>g</tt> given an edge range <tt>[first,last)</tt>.
</td>
<tr>

<tr>
<td>
<pre>G g(first, last, n_vertices, n_edges);</pre>
Construct graph object <tt>g</tt> given an edge range
<tt>[first,last)</tt>, the number of vertices, and the number of
edges.  Sometimes this constructor is more efficient than the
constructor lacking the graph size information.
</td>
</tr>

</Table>


<!--
<H3>Concept Checking Class</H3>

<PRE>
</PRE>
-->

<br>
<HR>
<TABLE>
<TR valign=top>
<TD nowrap>Copyright &copy 2000-2001</TD><TD>
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
Indiana University (<A
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
Indiana University (<A
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
</TD></TR></TABLE>

</BODY>
</HTML>