Boost logo

Boost Users :

From: sr kumar (srgama_at_[hidden])
Date: 2005-07-13 09:01:19


Hi,
I am attempting use bundled properties for my graph processing.
My attempt to 'write_graphviz' fails because of a lack of an
vertex_index as an internal property.

But how does one specify this? Named params do not seem to be
an option. Being new to the template meta programming game,
I am having some trouble figuring out how to make this work.

Code snippet below is the simplest that would reproduce my problem.

Thanks in advance for any clues/hints on how to proceed.
-sr

#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/topological_sort.hpp>
#include <boost/graph/graphviz.hpp>

using namespace boost;
using namespace std;

class A {
public:
   // dummy class
};

typedef struct VertexProperties {
    A* a;
    std::size_t index;
    boost::default_color_type color;
} VertexProperties;

typedef struct EdgeProperties {
    A* a;
} EdgeProperties;

int main(void) {

    typedef adjacency_list<vecS, listS, directedS, VertexProperties,
EdgeProperties> Graph;

    Graph g(3);

    property_map<Graph, std::size_t VertexProperties::*>::type
        id = get(&VertexProperties::index, g);
    property_map<Graph, boost::default_color_type VertexProperties::*>::type
        color = get(&VertexProperties::color, g);

    boost::graph_traits<Graph>::vertex_iterator vi, viend;
    int vnum = 0;
    for (boost::tie(vi,viend) = vertices(g);
            vi != viend; ++vi) {
        id[*vi] = vnum++;
    }

    add_edge(vertex(0, g), vertex(1, g), g);
    add_edge(vertex(2, g), vertex(1, g), g);

    typedef graph_traits<Graph>::vertex_descriptor vertex_descriptor;
    std::vector< vertex_descriptor > c;
    // Just check to ensure that all is ok.
    topological_sort(g, std::back_inserter(c),
            color_map(color).
            vertex_index_map(id));

    // See error below...
    property_map<Graph, vertex_index_t>::const_type
        ver_idx = get(vertex_index_t(),g);

    remove_edge(vertex(0, g), vertex(1, g), g);
    remove_edge(vertex(2, g), vertex(1, g), g);
    return 0;
};

// -------------
C:\test>cl /EHsc /IC:\CheckMate\boost\boost_1_32_0 btest.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50215.44 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.

btest.cpp
btest.cpp(53) : error C2440: 'initializing' : cannot convert from
'boost::adj_list_vertex_property_map<Graph,ValueType,Reference,Tag>'
to 'boost::adj_list_vertex_property_map<Graph,ValueType,Reference,Tag>'
        with
        [
            Graph=Graph,
            ValueType=boost::detail::error_property_not_found,
            Reference=boost::detail::error_property_not_found &,
            Tag=boost::vertex_index_t
        ]
        and
        [
            Graph=Graph,
            ValueType=boost::detail::error_property_not_found,
            Reference=const boost::detail::error_property_not_found &,
            Tag=boost::vertex_index_t
        ]
        No constructor could take the source type, or constructor
overload resolution was ambiguous


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