Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2001-01-26 16:56:13


Hi,

The first parameter is the EdgeList and the second parameter
is the VertexList.

So in the code below you have a VertexList of setS, so there is
no builtin vertex_index property.

If instead you use the graph type

    typedef boost::adjacency_list<boost::setS, boost::vecS,
                boost::bidirectionalS> Graph;

then you will have an EdgeList of setS, and a VertexList of
vecS, and your example will compile.

Hope this helps,
Jeremy

On Fri, 26 Jan 2001 bta_at_[hidden] wrote:

bta> Thank you for the rapid reply Jeremy. I understand the problem now
bta> given your clarification. I was able to remove the vertex_index_t
bta> property from the adjacency_list template and get it to compile and
bta> run with the expected output. However, it was also required to change
bta> the EdgeList from a setS to vecS for compilation. This seems odd given
bta> that I have yet to play with the edges at all. There does not seem to
bta> be a requirement that the vertex and edge list use the same container
bta> types (several examples use listS and vecS, respectively). The
bta> following code fails to compile (error messages follow). It works fine
bta> with the EdgeList set to a vecS container. Thanks again for the help.
bta>
bta> B.T. Adams
bta>
bta> #include <iostream>
bta> #include <boost/graph/adjacency_list.hpp>
bta> #include <boost/property_map.hpp>
bta>
bta> int main()
bta> {
bta> // Set the graph characteristics
bta> typedef boost::adjacency_list<boost::vecS, boost::setS,
bta> boost::bidirectionalS> Graph;
bta> //typedef boost::adjacency_list<boost::vecS, boost::vecS,
bta> // boost::bidirectionalS> Graph;
bta> typedef Graph::vertex_iterator vertex_iterator;
bta>
bta> // Declare some graph variables.
bta> Graph graph1;
bta>
bta> const int nnodes = 4;
bta>
bta> boost::property_map<Graph, boost::vertex_index_t>::type v_index =
bta> get(boost::vertex_index, graph1);
bta> // Add a vertex corresponding to each input node.
bta> std::pair<vertex_iterator, vertex_iterator> vp;
bta>
bta> for (int n = 0; n < nnodes; n++)
bta> boost::add_vertex(graph1);
bta>
bta> std::cout << "vertices via add_vertex = ";
bta> for (vp = vertices(graph1); vp.first != vp.second; ++vp.first)
bta> std::cout << v_index[*vp.first] << " ";
bta> std::cout << std::endl;
bta> std::cout << std::endl;
bta>
bta> // Use a constructor with the number of vertices predefined.
bta> Graph graph2(nnodes);
bta> v_index = get(boost::vertex_index, graph2);
bta>
bta> std::cout << "vertices via constructor = ";
bta> for (vp = vertices(graph2); vp.first != vp.second; ++vp.first)
bta> std::cout << v_index[*vp.first] << " ";
bta> std::cout << std::endl;
bta> std::cout << std::endl;
bta>
bta> return 0;
bta> }
bta>
bta> "/home/bta/linux/include/boost/graph/detail/adjacency_list.hpp", line
bta> 2212: error:
bta> no instance of overloaded function
bta> "boost::get_property_value"
bta> matches the argument list
bta> argument types are: (boost::no_property,
bta>
bta> boost::adj_list_vertex_property_map<boost::adjacency_list
bta> <boost::vecS, boost::setS,
bta> boost::bidirectionalS,
bta> boost::no_property, boost::no_property,
bta> boost::no_property>,
bta>
bta> boost::detail::vertex_property_map<boost::adjacency_list<
bta> boost::vecS, boost::setS, boost::bidirectionalS,
bta> boost::no_property, boost::no_property,
bta> boost::no_property>,
bta> boost::vertex_index_t>::Property,
bta> boost::vertex_index_t>::value_type,
bta> boost::vertex_index_t
bta> )
bta> return get_property_value(sv->m_property, value_type(),
bta> Tag());
bta> ^
bta> detected during instantiation of
bta> "boost::adj_list_vertex_property_map<Graph,
bta> Property,
bta> Tag>::value_type
bta> &boost::adj_list_vertex_property_map<Graph,
bta> Property,
bta>
bta> Tag>::operator[](boost::adj_list_vertex_property_map<Graph,
bta> Property, Tag>::key_type) [with
bta> Graph=boost::adjacency_list<boost::vecS,
bta> boost::setS,
bta> boost::bidirectionalS, boost::no_property,
bta> boost::no_property, boost::no_property>,
bta>
bta> Property=boost::detail::vertex_property_map<boost::adjacenc
bta> y_list<boost::vecS, boost::setS,
bta> boost::bidirectionalS,
bta> boost::no_property, boost::no_property,
bta> boost::no_property>,
bta> boost::vertex_index_t>::Property,
bta> Tag=boost::vertex_index_t]" at line 29 of
bta> "/home/bta/draco/src/graph/graph.cc"
bta>
bta> "/home/bta/draco/src/graph/graph.cc", line 29: error: no operator "<<"
bta> matches
bta> these operands
bta> operand types are: std::ostream <<
bta>
bta> boost::adj_list_vertex_property_map<boost::adjacency_list
bta> <boost::vecS, boost::setS,
bta> boost::bidirectionalS,
bta> boost::no_property, boost::no_property,
bta> boost::no_property>,
bta>
bta> boost::detail::vertex_property_map<boost::adjacency_list<
bta> boost::vecS, boost::setS, boost::bidirectionalS,
bta> boost::no_property, boost::no_property,
bta> boost::no_property>,
bta> boost::vertex_index_t>::Property,
bta> boost::vertex_index_t>::value_type
bta> std::cout << v_index[*vp.first] << " ";
bta>
bta>
bta> etc.......
bta>
bta> ^
bta>
bta>
bta>
bta>
bta>
bta>

----------------------------------------------------------------------
 Jeremy Siek www: http://www.lsc.nd.edu/~jsiek/
 Ph.D. Candidate email: jsiek_at_[hidden]
 Univ. of Notre Dame work phone: (219) 631-3906
----------------------------------------------------------------------


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk