1 | <HTML> |
---|
2 | <!-- |
---|
3 | -- Copyright (c) Jeremy Siek 2000 |
---|
4 | -- |
---|
5 | -- Permission to use, copy, modify, distribute and sell this software |
---|
6 | -- and its documentation for any purpose is hereby granted without fee, |
---|
7 | -- provided that the above copyright notice appears in all copies and |
---|
8 | -- that both that copyright notice and this permission notice appear |
---|
9 | -- in supporting documentation. Silicon Graphics makes no |
---|
10 | -- representations about the suitability of this software for any |
---|
11 | -- purpose. It is provided "as is" without express or implied warranty. |
---|
12 | --> |
---|
13 | <Head> |
---|
14 | <Title>AdjacencyGraph</Title> |
---|
15 | <BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b" |
---|
16 | ALINK="#ff0000"> |
---|
17 | <IMG SRC="../../../boost.png" |
---|
18 | ALT="C++ Boost" width="277" height="86"> |
---|
19 | |
---|
20 | <BR Clear> |
---|
21 | |
---|
22 | |
---|
23 | |
---|
24 | <H2><A NAME="concept:AdjacencyGraph"></A> |
---|
25 | AdjacencyGraph |
---|
26 | </H2> |
---|
27 | |
---|
28 | The AdjacencyGraph concept provides and interface for efficient access |
---|
29 | of the adjacent vertices to a vertex in a graph. This is quite similar |
---|
30 | to the <a href="./IncidenceGraph.html">IncidenceGraph</a> concept (the |
---|
31 | target of an out-edge is an adjacent vertex). Both concepts are |
---|
32 | provided because in some contexts there is only concern for the |
---|
33 | vertices, whereas in other contexts the edges are also important. |
---|
34 | |
---|
35 | <H3>Refinement of</H3> |
---|
36 | |
---|
37 | <a href="Graph.html">Graph</a> |
---|
38 | |
---|
39 | <h3>Notation</h3> |
---|
40 | |
---|
41 | <Table> |
---|
42 | <TR> |
---|
43 | <TD><tt>G</tt></TD> |
---|
44 | <TD>A type that is a model of Graph.</TD> |
---|
45 | </TR> |
---|
46 | |
---|
47 | <TR> |
---|
48 | <TD><tt>g</tt></TD> |
---|
49 | <TD>An object of type <tt>G</tt>.</TD> |
---|
50 | </TR> |
---|
51 | |
---|
52 | <TR> |
---|
53 | <TD><tt>v</tt></TD> |
---|
54 | <TD>An object of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD> |
---|
55 | </TR> |
---|
56 | |
---|
57 | </table> |
---|
58 | |
---|
59 | |
---|
60 | <H3>Associated Types</H3> |
---|
61 | |
---|
62 | <Table border> |
---|
63 | |
---|
64 | <tr> |
---|
65 | <td><tt>boost::graph_traits<G>::traversal_category</tt><br><br> |
---|
66 | This tag type must be convertible to <tt>adjacency_graph_tag</tt>. |
---|
67 | </td> |
---|
68 | </tr> |
---|
69 | |
---|
70 | <TR> |
---|
71 | <TD><pre>boost::graph_traits<G>::adjacency_iterator</pre> |
---|
72 | An adjacency iterator for a vertex <i>v</i> provides access to the |
---|
73 | vertices adjacent to <i>v</i>. As such, the value type of an |
---|
74 | adjacency iterator is the vertex descriptor type of its graph. An |
---|
75 | adjacency iterator must meet the requirements of <a |
---|
76 | href="../../utility/MultiPassInputIterator.html">MultiPassInputIterator</a>. |
---|
77 | </TD> |
---|
78 | </TR> |
---|
79 | |
---|
80 | </table> |
---|
81 | |
---|
82 | <h3>Valid Expressions</h3> |
---|
83 | |
---|
84 | |
---|
85 | <table border> |
---|
86 | |
---|
87 | <tr> |
---|
88 | <td><a name="sec:adjacent-vertices"><TT>adjacent_vertices(v, g)</TT></a></TD> |
---|
89 | <TD> |
---|
90 | Returns an iterator-range providing access to the vertices adjacent to |
---|
91 | vertex <TT>v</TT> in graph <TT>g</TT>.<a |
---|
92 | href="#1">[1]</a> |
---|
93 | |
---|
94 | <br> Return type: |
---|
95 | <TT>std::pair<adjacency_iterator, adjacency_iterator></TT> |
---|
96 | </TD> |
---|
97 | </TR> |
---|
98 | |
---|
99 | </table> |
---|
100 | |
---|
101 | <H3>Complexity guarantees</H3> |
---|
102 | |
---|
103 | The <TT>adjacent_vertices()</TT> function must return in constant time. |
---|
104 | |
---|
105 | <H3>See Also</H3> |
---|
106 | |
---|
107 | <a href="./graph_concepts.html">Graph concepts</a>, |
---|
108 | <a href="./adjacency_iterator.html"><tt>adjacency_iterator</tt></a> |
---|
109 | |
---|
110 | <H3>Concept Checking Class</H3> |
---|
111 | |
---|
112 | <PRE> |
---|
113 | template <class G> |
---|
114 | struct AdjacencyGraphConcept |
---|
115 | { |
---|
116 | typedef typename boost::graph_traits<G>::adjacency_iterator |
---|
117 | adjacency_iterator; |
---|
118 | void constraints() { |
---|
119 | function_requires< IncidenceGraphConcept<G> >(); |
---|
120 | function_requires< MultiPassInputIteratorConcept<adjacency_iterator> >(); |
---|
121 | |
---|
122 | p = adjacent_vertices(v, g); |
---|
123 | v = *p.first; |
---|
124 | const_constraints(g); |
---|
125 | } |
---|
126 | void const_constraints(const G& g) { |
---|
127 | p = adjacent_vertices(v, g); |
---|
128 | } |
---|
129 | std::pair<adjacency_iterator,adjacency_iterator> p; |
---|
130 | typename boost::graph_traits<G>::vertex_descriptor v; |
---|
131 | G g; |
---|
132 | }; |
---|
133 | </PRE> |
---|
134 | |
---|
135 | <h3>Design Rationale</h3> |
---|
136 | |
---|
137 | The AdjacencyGraph concept is somewhat frivolous since <a |
---|
138 | href="./IncidenceGraph.html">IncidenceGraph</a> really covers the same |
---|
139 | functionality (and more). The AdjacencyGraph concept exists because |
---|
140 | there are situations when <tt>adjacent_vertices()</tt> is more |
---|
141 | convenient to use than <tt>out_edges()</tt>. If you are constructing a |
---|
142 | graph class and do not want to put in the extra work of creating an |
---|
143 | adjacency iterator, have no fear. There is an adaptor class named <a |
---|
144 | href="./adjacency_iterator.html"> <tt>adjacency_iterator</tt></a> that |
---|
145 | you can use to create an adjacency iterator out of an out-edge |
---|
146 | iterator. |
---|
147 | |
---|
148 | <h3>Notes</h3> |
---|
149 | |
---|
150 | <a name="1">[1]</a> The case of a |
---|
151 | <I>multigraph</I> (where multiple edges can connect the same two |
---|
152 | vertices) brings up an issue as to whether the iterators returned by |
---|
153 | the <TT>adjacent_vertices()</TT> function access a range that |
---|
154 | includes each adjacent vertex once, or whether it should match the |
---|
155 | behavior of the <TT>out_edges()</TT> function, and access a |
---|
156 | range that may include an adjacent vertex more than once. For now the |
---|
157 | behavior is defined to match that of <TT>out_edges()</TT>, |
---|
158 | though this decision may need to be reviewed in light of more |
---|
159 | experience with graph algorithm implementations. |
---|
160 | |
---|
161 | |
---|
162 | |
---|
163 | <br> |
---|
164 | <HR> |
---|
165 | <TABLE> |
---|
166 | <TR valign=top> |
---|
167 | <TD nowrap>Copyright © 2000-2001</TD><TD> |
---|
168 | <A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>) |
---|
169 | </TD></TR></TABLE> |
---|
170 | |
---|
171 | </BODY> |
---|
172 | </HTML> |
---|