Boost logo

Boost Users :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2004-02-03 09:00:53


Hi Hugues,

I think that is a bug. I'll look into fixing it.

Regards,
Jeremy

On Feb 3, 2004, at 8:32 AM, Hugues Joly wrote:

> Hi,
> I'm posting again a question that got confused due
> to mistakes from my part...
>
> I'd like to clarify a point about internal properties
> accessed through a subgraph. According to the
> documentation of the method "get(PropertyTag,
> subgraph& g)":
>
> "vertex and edge properties are shared by all
> subgraphs, so changes to a property through a local
> vertex descriptor for one subgraph will change the
> property for the global vertex descriptor, and
> therefore for all other subgraphs."
> (c.f. boost-1.30.2/libs/graph/doc/subgraph.html)
>
> Here, I'm sending you a small program inspired by
> the
> boost-1.30.2/libs/graph/example/subgraph.cpp example.
>> From its behavior, it seems that:
>
> 1) A property value is not shared between the global
> descriptor and its corresponding local descriptors.
>
> 2) we need to initialize property values for each of
> the subgraphs. For example, if I set a name "A" for
> the global vertex descriptor A, that property is not
> seen through the corresponding local vertex
> descriptors.
>
> Is this a case of misuse or is it a bug?
>
> __________________________________________________________
> Lèche-vitrine ou lèche-écran ?
> magasinage.yahoo.ca/*
> Sample output:
>
> After initializing properties for G1:
> Global and local properties for vertex G0[C]...
> G0[C]= C
> G1[A1]= A1
> Global and local properties for vertex G0[E]...
> G0[E]= E
> G1[B1]= B1
> Global and local properties for vertex G0[F]...
> G0[F]= F
> G1[C1]= C1
>
> After initializing properties for G2:
> Global and local properties for vertex G0[A]
> G0[A]= A
> G2[A2]= A2
> Global and local properties for vertex G0[C]...
> G0[C]= C
> G1[A1]= A1
> G2[B2]= B2
>
> */
>
> #include <boost/config.hpp>
> #include <iostream>
> #include <boost/graph/subgraph.hpp>
> #include <boost/graph/adjacency_list.hpp>
> #include <boost/graph/graph_utility.hpp>
>
> int main(int,char*[])
> {
> using namespace boost;
> //typedef adjacency_list_traits<vecS, vecS, directedS> Traits;// Does
> nothing?
> typedef property< vertex_color_t, int,
> property< vertex_name_t, std::string > > VertexProperty;
>
> typedef subgraph< adjacency_list< vecS, vecS, directedS,
> VertexProperty, property<edge_index_t, int> > > Graph;
>
> const int N = 6;
> Graph G0(N);
> enum { A, B, C, D, E, F}; // for conveniently refering to
> vertices in G0
>
> property_map<Graph, vertex_name_t>::type name = get(vertex_name_t(),
> G0);
> name[A] = "A";
> name[B] = "B";
> name[C] = "C";
> name[D] = "D";
> name[E] = "E";
> name[F] = "F";
>
> Graph& G1 = G0.create_subgraph();
> enum { A1, B1, C1 }; // for conveniently refering to
> vertices in G1
>
> add_vertex(C, G1); // global vertex C becomes local A1 for G1
> add_vertex(E, G1); // global vertex E becomes local B1 for G1
> add_vertex(F, G1); // global vertex F becomes local C1 for G1
>
> property_map<Graph, vertex_name_t>::type name1 = get(vertex_name_t(),
> G1);
> name1[A1] = "A1";
>
> std::cout << std::endl << "After initializing properties for G1:" <<
> std::endl;
> std::cout << " Global and local properties for vertex G0[C]..." <<
> std::endl;
> std::cout << " G0[C]= " << boost::get(vertex_name, G0, C) <<
> std::endl;// prints: "G0[C]= C"
> std::cout << " G1[A1]= " << boost::get(vertex_name, G1, A1) <<
> std::endl;// prints: "G1[A1]= A1"
>
> name1[B1] = "B1";
>
> std::cout << " Global and local properties for vertex G0[E]..." <<
> std::endl;
> std::cout << " G0[E]= " << boost::get(vertex_name, G0, E) <<
> std::endl;// prints: "G0[E]= E"
> std::cout << " G1[B1]= " << boost::get(vertex_name, G1, B1) <<
> std::endl;// prints: "G1[B1]= B1"
>
> name1[C1] = "C1";
>
> std::cout << " Global and local properties for vertex G0[F]..." <<
> std::endl;
> std::cout << " G0[F]= " << boost::get(vertex_name, G0, F) <<
> std::endl;// prints: "G0[F]= F"
> std::cout << " G1[C1]= " << boost::get(vertex_name, G1, C1) <<
> std::endl;// prints: "G1[C1]= C1"
>
> Graph& G2 = G0.create_subgraph();
> enum { A2, B2 }; // for conveniently refering to
> vertices in G2
>
> add_vertex(A, G2); // global vertex A becomes local A2 for G2
> add_vertex(C, G2); // global vertex C becomes local B2 for G2
>
> property_map<Graph, vertex_name_t>::type name2 = get(vertex_name_t(),
> G2);
> name2[A2] = "A2";
>
> std::cout << std::endl << std::endl << "After initializing properties
> for G2:" << std::endl;
> std::cout << " Global and local properties for vertex G0[A]" <<
> std::endl;
> std::cout << " G0[A]= " << boost::get(vertex_name, G0, A) <<
> std::endl;// prints: "G0[A]= A"
> std::cout << " G2[A2]= " << boost::get(vertex_name, G2, A2) <<
> std::endl;// prints: "G2[A2]= A2"
>
> name2[B2] = "B2";
>
> std::cout << " Global and local properties for vertex G0[C]..." <<
> std::endl;
> std::cout << " G0[C]= " << boost::get(vertex_name, G0, C) <<
> std::endl;// prints: "G0[C]= C"
> std::cout << " G1[A1]= " << boost::get(vertex_name, G1, A1) <<
> std::endl;// prints: "G1[A1]= A1"
> std::cout << " G2[B2]= " << boost::get(vertex_name, G2, B2) <<
> std::endl;// prints: "G2[B2]= B2"
>
> return 0;
> }
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
_______________________________________________
Jeremy Siek <jsiek_at_[hidden]>
http://www.osl.iu.edu.edu/~jsiek
Ph.D. Student, Indiana University Bloomington
C++ Booster (http://www.boost.org)
Office phone: (812) 856-1820
_______________________________________________


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