Boost logo

Boost Users :

From: Shufei Fan (fansf_at_[hidden])
Date: 2007-04-04 17:08:48


Doug Gregor <dgregor <at> cs.indiana.edu> writes:

>
>
> There is no automatic re-indexing in the BGL. It's a feature that
> we'd like to have, but probably it would be in the context of a new
> graph type.
>
> Cheers,
> Doug
>
Thanks! but, in my trial, based on the 'quick_tour.cpp' example, when I added
a few lines at the end of main():

  ///////////////////////////////////////////////////////////////////////////
  //the following is a test of re-indexing, after removing certain node...
  std::cout << "try delete node No.2, output is: " << std::endl;
  typedef graph_traits<Graph>::vertex_descriptor Vertex;
  typedef graph_traits<Graph>::vertex_iterator VertexIter;
  Vertex ver;
  VertexIter ver_iter;
  ver_iter = vertices(g).first;
  std::advance(ver_iter, 2);//advance iterator 2 positions.
  clear_vertex(*ver_iter, g);
  remove_vertex(*ver_iter, g);
  std::for_each(vertices(g).first, vertices(g).second,
                exercise_vertex<Graph>(g));

  boost::write_graphviz(std::cout, g,
                        make_label_writer(vertex_id),//name
                        make_label_writer(trans_delay),
                        make_graph_attributes_writer(graph_attr, vertex_attr,
                                                     edge_attr));
  ///////////////////////////////////////////////////////////////////////////

It's output is:

vertices(g) = A B C D E
edges(g) = (A,B) (A,D) (C,A) (D,C) (C,E) (B,D) (D,E)
vertex: 0
        out-edges: (0,1) (0,3)
        in-edges: (2,0)
        adjacent vertices: 1 3
vertex: 1
        out-edges: (1,3)
        in-edges: (0,1)
        adjacent vertices: 3
vertex: 2
        out-edges: (2,0) (2,4)
        in-edges: (3,2)
        adjacent vertices: 0 4
vertex: 3
        out-edges: (3,2) (3,4)
        in-edges: (0,3) (1,3)
        adjacent vertices: 2 4
vertex: 4
        out-edges:
        in-edges: (2,4) (3,4)
        adjacent vertices:
digraph G {
graph [
rankdir="LR", ratio="fill", size="3,3"];
node [
shape="circle"];
0[label="0"];
1[label="1"];
2[label="2"];
3[label="3"];
4[label="4"];
0->1 [label="1.2"];
0->3 [label="4.5"];
2->0 [label="2.6"];
3->2 [label="0.4"];
2->4 [label="5.2"];
1->3 [label="1.8"];
3->4 [label="3.3"];
}
try delete node No.2, output is:
vertex: 0
        out-edges: (0,1) (0,2)
        in-edges:
        adjacent vertices: 1 2
vertex: 1
        out-edges: (1,2)
        in-edges: (0,1)
        adjacent vertices: 2
vertex: 2
        out-edges: (2,3)
        in-edges: (0,2) (1,2)
        adjacent vertices: 3
vertex: 3
        out-edges:
        in-edges: (2,3)
        adjacent vertices:
digraph G {
graph [
rankdir="LR", ratio="fill", size="3,3"];
node [
shape="circle"];
0[label="0"];
1[label="1"];
2[label="2"];
3[label="3"];
0->1 [label="1.2"];
0->2 [label="4.5"];
1->2 [label="1.8"];
2->3 [label="3.3"];
}

Am I wrong with displaying the vertex index(which seems to re-adjusted
automatically by itself)?

Thanks
Shufei


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net