[prev in list] [next in list] [prev in thread] [next in thread] 

List:       boost-users
Subject:    [Boost-users] howto store vertex-iterators as internal graph
From:       Sebastian Weber <sebastian.weber () physik ! tu-darmstadt ! de>
Date:       2004-11-29 11:53:52
Message-ID: 41AB0DD0.9070104 () physik ! tu-darmstadt ! de
[Download RAW message or body]

Hi folks!

I got a cyclic type-dependency problem. I am trying to let every vertex 
store a iterator to a list which stores vertex-iterators. This sounds 
weired, but I need to keep track of very few vertices within my graph 
which have a particle located at it. Thus I created a list of 
vertex-iterators who carry my particle positions in the graph. In order 
to be able to tell quickly if a vertice is taken by a particle I want 
each vertice to include a pointer to a null element representing the 
absence of a particle or a pointer into that list. My non-working code 
looks like:

Definition of my graph:

struct Spot {
   // acutally I need the vertex_iterator to be defined already
   // in order to define particle, but this is not yet defined
   // so I am using the knowledge that it is going to be represented
   // by a vector<std::size_t>::iterator (at least I hope so)
   // this assumption is WRONG!!
   typedef std::list< std::vector<std::size_t>::iterator >::iterator \\
	particle_t;
   particle_t particle;
};

typedef boost::adjacency_list<boost::vecS, boost::vecS, \\
	boost::undirectedS, Spot > graph_t;


Here I initialise my particles to be distributed in the graph object bg.
m_posA is of type: std::list<RandomGraph::gtraits::vertex_iterator>

// first initialise every position to the null-flag
for(; vi != vend; ++vi)
   bg[*vi].particle = Spot::particle_t();

// now place particles at random positions
boost::tie(vi, vend) = boost::vertices(bg);

for(std::size_t i = 0; i < initialA; i++) {
   std::size_t pos;
   //aList_t::iterator iter;
   // find a random empty vertice
   do {
     pos = rand_gen();
   } while(bg[pos].particle != m_posA_end);
   // place particle A there
   RandomGraph::gtraits::vertex_iterator vref = vi + pos;
   // put returns an iterator to the list-element where
   // vref has been stored
   bg[pos].particle = m_posA.put(vref);
}


Any help would be great.

Thanks in adavance.

Greetings,

Sebastian Weber

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic