C++ Boost

MutableGraph

A MutableGraph can be changed via the addition or removal of edges and vertices.

Refinement of

Graph

Notation

G A type that is a model of Graph.
g An object of type G.
e An object of type boost::graph_traits<G>::edge_descriptor.
u,v are objects of type boost::graph_traits<G>::vertex_descriptor.

Valid Expressions

add_edge(g, u, v) Inserts the edge (u,v) into the graph.
Return type: std::pair<edge_descriptor, bool>
remove_edge(g, u, v) Remove the edge (u,v) from the graph. If the graph allows parallel edges this remove all occurances of (u,v).
Return type: void
Precondition: u and v are vertices in the graph.
Postcondition: (u,v) is no longer in the edge set for g.
remove_edge(g, e) Remove the edge e from the graph.
Return type: void<>
Precondition: e is an edge in the graph.
Postcondition: e is no longer in the edge set for g.
add_vertex(g) Add a new vertex to the graph. The vertex_descriptor for the new vertex is returned.
Return type: vertex_descriptor
clear_vertex(g, u) Remove all edges to and from vertex u from the graph.
Return type: void
Precondition: u is a valid vertex descriptor of g.
Postcondition: u does not appear as a source or target of any edge in g.
remove_vertex(g, u) Remove u 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 u. Typically the clear_vertex() function should be called first.
Return type: void
Precondition: u is a valid vertex descriptor of g.
Postcondition: num_vertices(g) is one less, u no longer appears in the vertex set of the graph and it is no longer a valid vertex descriptor.

Complexity Guarantees

Models

Concept Checking Class

  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;
  };


Copyright © 2000 Jeremy Siek, Univ.of Notre Dame (jsiek@lsc.nd.edu)