breadth_first_searchable graph, without invalidable vertex descriptors
Hello, I am trying to use the BCG as backbone for a ControlFlowGraph in a compiler project. It seems that I cannot use BCG for this task because of the follow contradicting (from BCG point of view) requirements: 1. I want to be able to breadth_first_search through my graph. 2. I want to be able to keep descriptors to vertices 'for ever' so I can refer a specific vertex at any given time (for removal or whatever other reasons). To implement requirement 1 my adjacency_list should have its VertexList of type vecS. To implement requirement 2 my adjacency_list should have its VertexList of type listS. Unfortunately those are mutualy exclusive and it seems that BCG is unsuited for the job. But I can't really think of a decent generic graph library unable to support those requirements. After all, it's all about being able to use basic graph traversals on randomly mutating graphs. STL has the list which has those nice properties, why a graph library should be different?! Perhaps I am missing something and I am asking for help: how should I declare my graph and how can I do a bfs on it? Thanks in advance, Cristi
Hi Cristy, On Wed, 21 Nov 2001 cristipp@ics.uci.edu wrote: cristi> I am trying to use the BCG as backbone for a ControlFlowGraph in a cristi> compiler project. It seems that I cannot use BCG for this task cristi> because of the follow contradicting (from BCG point of view) cristi> requirements: What is BCG? I will assume you mean the boost::adjacency_list class. cristi> 1. I want to be able to breadth_first_search through my graph. cristi> 2. I want to be able to keep descriptors to vertices 'for ever' so I cristi> can refer a specific vertex at any given time (for removal or cristi> whatever other reasons). cristi> cristi> To implement requirement 1 my adjacency_list should have its cristi> VertexList of type vecS. This is not required. The VertexList can be listS. However, you do need to provide your own color map parameter if you use listS. Cheers, Jeremy ---------------------------------------------------------------------- Jeremy Siek http://php.indiana.edu/~jsiek/ Ph.D. Student, Indiana Univ. B'ton email: jsiek@osl.iu.edu C++ Booster (http://www.boost.org) office phone: (812) 855-3608 ----------------------------------------------------------------------
Thanks. I added the vertex_color property to my graph and it works
just fine.
As a BGL (and not BCG :-)) novice I would like to understand why the
breadth_first_search compiles for boost::adjacency_list with
VertexType vecS, but not for boost::adjacency_list with VertexType
listS (unless the colormap is passed as a parameter). Is there any
piece of documentation I should have read and I did not? Or could
anybody explain this for us, the big herd of users?
Keep up the good work!
Cristi
--- In Boost-Users@y..., Jeremy Siek
Hi Cristy,
On Wed, 21 Nov 2001 cristipp@i... wrote: cristi> I am trying to use the BCG as backbone for a ControlFlowGraph in a cristi> compiler project. It seems that I cannot use BCG for this task cristi> because of the follow contradicting (from BCG point of view) cristi> requirements:
What is BCG? I will assume you mean the boost::adjacency_list class.
cristi> 1. I want to be able to breadth_first_search through my graph. cristi> 2. I want to be able to keep descriptors to vertices 'for ever' so I cristi> can refer a specific vertex at any given time (for removal or cristi> whatever other reasons). cristi> cristi> To implement requirement 1 my adjacency_list should have its cristi> VertexList of type vecS.
This is not required. The VertexList can be listS. However, you do need to provide your own color map parameter if you use listS.
Cheers, Jeremy
-------------------------------------------------------------------- -- Jeremy Siek http://php.indiana.edu/~jsiek/ Ph.D. Student, Indiana Univ. B'ton email: jsiek@o... C++ Booster (http://www.boost.org) office phone: (812) 855-3608 -------------------------------------------------------------------- --
From adjacency_list.html: "If the VertexList of the graph is vecS, then the graph has a builtin vertex indices accessed via the property map for the vertex_index_t
On Wed, 21 Nov 2001 cristipp@ics.uci.edu wrote:
cristi> Thanks. I added the vertex_color property to my graph and it works
cristi> just fine.
Great!
cristi> As a BGL (and not BCG :-)) novice I would like to
cristi> understand why the breadth_first_search compiles for
cristi> boost::adjacency_list with VertexType vecS, but not for
cristi> boost::adjacency_list with VertexType listS (unless the
cristi> colormap is passed as a parameter). Is there any piece of
cristi> documentation I should have read and I did not? Or could
cristi> anybody explain this for us, the big herd of users?
Sure.
Take a look at the docs in breadth_first_search.html, specifically the
color_map named parameter. As with most named parameters, you can
either pass in an argument, or use the default. The default in
this case is:
"Default: an iterator_property_map created from a std::vector of
default_color_type of size num_vertices(g) and using the i_map for the
index map."
where i_map is the vertex index map given as another named paremeter:
"IN: vertex_index_map(VertexIndexMap i_map)
This maps each vertex to an integer in the range [0, num_vertices(g)).
This parameter is only necessary when the default color property map is
used. The type VertexIndexMap must be a model of Readable Property Map.
The value type of the map must be an integer type. The vertex
descriptor type of the graph needs to be usable as the key type of the map.
Default: get(vertex_index, g)"
Now, an adjacency_list only has a builtin vertex index map if it
has VertexList=vecS:
property."
Alternatively, you could add a vertex index map to an adjacency_list with
VertexList=listS using a property
I've attached an example of using breadth_first_search with an
adjacency_list where VertexList=listS.
Cheers,
Jeremy
On Tue, 20 Nov 2001, Jeremy Siek wrote:
jsiek> cristi> To implement requirement 1 my adjacency_list should have its
jsiek> cristi> VertexList of type vecS.
jsiek>
jsiek> This is not required. The VertexList can be listS. However, you do need
jsiek> to provide your own color map parameter if you use listS.
----------------------------------------------------------------------
Jeremy Siek http://php.indiana.edu/~jsiek/
Ph.D. Student, Indiana Univ. B'ton email: jsiek@osl.iu.edu
C++ Booster (http://www.boost.org) office phone: (812) 855-3608
----------------------------------------------------------------------
----------
//=======================================================================
// Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee,
//
// This file is part of the Boost Graph Library
//
// You should have received a copy of the License Agreement for the
// Boost Graph Library along with the software; see the file LICENSE.
// If not, contact Office of Research, Indiana University,
// Bloomington, IN 47405.
//
// Permission to modify the code and to distribute the code is
// granted, provided the text of this NOTICE is retained, a notice if
// the code was modified is included with the above COPYRIGHT NOTICE
// and with the COPYRIGHT NOTICE in the LICENSE file, and that the
// LICENSE file is distributed with the modified code.
//
// LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.
// By way of example, but not limitation, Licensor MAKES NO
// REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY
// PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE COMPONENTS
// OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS
// OR OTHER RIGHTS.
//=======================================================================
#include
P.S. The attached example exposed a subtle const correctness bug in property_map.hpp. I've checked the fix into CVS, so you'll need to get an update. ---------------------------------------------------------------------- Jeremy Siek http://php.indiana.edu/~jsiek/ Ph.D. Student, Indiana Univ. B'ton email: jsiek@osl.iu.edu C++ Booster (http://www.boost.org) office phone: (812) 855-3608 ----------------------------------------------------------------------
participants (2)
-
cristipp@ics.uci.edu
-
Jeremy Siek