mirror of
https://github.com/boostorg/graph.git
synced 2026-01-31 08:12:14 +00:00
191 lines
4.5 KiB
HTML
191 lines
4.5 KiB
HTML
<HTML>
|
|
<!--
|
|
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes no
|
|
-- representations about the suitability of this software for any
|
|
-- purpose. It is provided "as is" without express or implied warranty.
|
|
-->
|
|
<Head>
|
|
<Title>MutableGraph</Title>
|
|
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
|
ALINK="#ff0000">
|
|
<IMG SRC="../../../c++boost.gif"
|
|
ALT="C++ Boost">
|
|
|
|
<BR Clear>
|
|
|
|
|
|
<H2><A NAME="sec:MutableGraph"></A>
|
|
MutableGraph
|
|
</H2>
|
|
|
|
A MutableGraph can be changed via the addition or removal of
|
|
edges and vertices.
|
|
|
|
<H3>Refinement of</H3>
|
|
|
|
<a href="./Graph.html">Graph</a>
|
|
|
|
<h3>Notation</h3>
|
|
|
|
<Table>
|
|
<TR>
|
|
<TD><tt>G</tt></TD>
|
|
<TD>A type that is a model of Graph.</TD>
|
|
</TR>
|
|
|
|
<TR>
|
|
<TD><tt>g</tt></TD>
|
|
<TD>An object of type <tt>G</tt>.</TD>
|
|
</TR>
|
|
|
|
<TR>
|
|
<TD><tt>e</tt></TD>
|
|
<TD>An object of type <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
|
</TR>
|
|
|
|
<TR>
|
|
<TD><tt>u,v</tt></TD>
|
|
<TD>are objects of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
|
</TR>
|
|
|
|
</table>
|
|
|
|
<H3>Valid Expressions</H3>
|
|
|
|
<table border>
|
|
|
|
<tr>
|
|
<TD><TT>add_edge(g, u, v)</TT></TD>
|
|
<TD>
|
|
Inserts the edge <i>(u,v)</i> into the graph.<br>
|
|
Return type: <TT>std::pair<edge_descriptor, bool></TT>
|
|
</TD>
|
|
</tr>
|
|
|
|
<tr>
|
|
<TD><TT>remove_edge(g, u, v)</TT></TD>
|
|
<TD>
|
|
Remove the edge <i>(u,v)</i> from the graph. If the
|
|
graph allows parallel edges this remove all occurances of
|
|
<i>(u,v)</i>.<br>
|
|
Return type: <TT>void</TT><br>
|
|
Precondition: <i>u</i> and <i>v</i> are vertices in the graph.<br>
|
|
Postcondition: <i>(u,v)</i> is no longer in the edge set for
|
|
<TT>g</TT>.<br>
|
|
</TD>
|
|
</TR>
|
|
|
|
<tr>
|
|
<TD><TT>remove_edge(g, e)</TT></TD>
|
|
<TD>Remove the edge <i>e</i> from the graph.<br>
|
|
Return type: <TT>void</TT><><br>
|
|
Precondition: <i>e</i> is an edge in the graph.<br>
|
|
Postcondition: <i>e</i> is no longer in the edge set for <TT>g</TT>.
|
|
</TD>
|
|
</TR>
|
|
|
|
<tr>
|
|
<TD><TT>add_vertex(g)</TT></TD>
|
|
<TD>
|
|
Add a new vertex to the graph. The <TT>vertex_descriptor</TT> for the
|
|
new vertex is returned.<br>
|
|
Return type: <TT>vertex_descriptor</TT>
|
|
</TD>
|
|
</TR>
|
|
|
|
<tr>
|
|
<TD><TT>clear_vertex(g, u)</TT></TD>
|
|
<TD>
|
|
Remove all edges to and from vertex <tt>u</tt> from the graph.<br>
|
|
Return type: <TT>void</TT><br>
|
|
Precondition: <tt>u</tt> is a valid vertex descriptor of <TT>g</TT>.<br>
|
|
Postcondition: <tt>u</tt> does not appear as a source or target of
|
|
any edge in <TT>g</TT>.
|
|
</TD>
|
|
</TR>
|
|
|
|
<tr>
|
|
<TD><TT>remove_vertex(g, u)</TT></TD>
|
|
<TD>
|
|
Remove <i>u</i> from the vertex set of the graph. Note that undefined
|
|
behaviour may result if there are edges remaining in the graph who's
|
|
target is <i>u</i>. Typically the <TT>clear_vertex()</TT> function
|
|
should be called first.<br>
|
|
Return type: <TT>void</TT><br>
|
|
Precondition: <TT>u</TT> is a valid vertex descriptor of <TT>g</TT>.<br>
|
|
Postcondition: <TT>num_vertices(g)</TT> is one less, <TT>u</TT>
|
|
no longer appears in the vertex set of the graph and it
|
|
is no longer a valid vertex descriptor.
|
|
</TD>
|
|
</TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
</LI>
|
|
</UL>
|
|
|
|
<P>
|
|
|
|
<H3>Complexity Guarantees</H3>
|
|
|
|
<P>
|
|
|
|
<UL>
|
|
<LI>Edge insertion must be either amortized constant time or it
|
|
can be <i>O(log(E/V))</i> if the insertion also checks to
|
|
prevent the addition of parallel edges (which is a ``feature'' of
|
|
some graph types).
|
|
</LI>
|
|
<LI>Edge removal is guaranteed to be <i>O(E)</i>.</LI>
|
|
<LI>Vertex insertion is guaranteed to be amortized constant time.</LI>
|
|
<LI>Clearing a vertex is <i>O(E + V)</i>.</LI>
|
|
<LI>Vertex removal is <i>O(E + V)</i>.</LI>
|
|
</UL>
|
|
|
|
<H3>Models</H3>
|
|
|
|
<UL>
|
|
<LI><TT>adjacency_list</TT>
|
|
</LI>
|
|
</UL>
|
|
|
|
|
|
<H3>Concept Checking Class</H3>
|
|
|
|
<PRE>
|
|
template <class G>
|
|
struct MutableGraph_concept
|
|
{
|
|
typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor;
|
|
void constraints() {
|
|
v = add_vertex(g);
|
|
clear_vertex(g, v);
|
|
remove_vertex(g, v);
|
|
p = add_edge(g, u, v);
|
|
remove_edge(g, u, v);
|
|
remove_edge(g, e);
|
|
}
|
|
G g;
|
|
edge_descriptor e;
|
|
std::pair<edge_descriptor, bool> p;
|
|
typename boost::graph_traits<G>::vertex_descriptor u, v;
|
|
};
|
|
</PRE>
|
|
|
|
<br>
|
|
<HR>
|
|
<TABLE>
|
|
<TR valign=top>
|
|
<TD nowrap>Copyright © 2000</TD><TD>
|
|
<A HREF=http://www.boost.org/people/jeremy_siek.htm>Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
|
</TD></TR></TABLE>
|
|
|
|
</BODY>
|
|
</HTML>
|