2009-06-12 10 views
2

J'essaie d'utiliser l'extension read_graphviz pour extraire un fichier .dot graphviz dans un Boost Grpah. Voici mon échantillon. Je ne peux pas le compiler. J'ai posté le message d'erreur g ++ après le code mais je devais le faire mais c'est court, c'est trop long pour poster ici sans re-formatage significatif.Impossible de compiler le code à l'aide de Boost graphviz.hpp

La documentation de la bibliothèque graphviz.hpp est trop laconique pour me guider dans la bonne direction. Quelqu'un a des pensées?

#include <iostream> 
#include <boost/graph/graph_traits.hpp> 
#include <boost/graph/adjacency_list.hpp> 
#include <boost/property_map.hpp> 
#include <boost/graph/graphviz.hpp> 

int main(int argc, char* argv[]) 
{ 
    assert(argc == 2); 

    std::ifstream dotFile(argv[1], std::ifstream::in); 

    typedef boost::adjacency_list<> Graph; 
    Graph graph(17); 

    boost::dynamic_properties properties; 
    boost::property_map< Graph, boost::vertex_name_t >::type name = get(boost::vertex_name, graph); 
    properties.property("node_id", name); 

    bool readResult; 
    readResult = read_graphviz(dotFile, graph, properties); 
    return 0; 

g++ -Wall -c -o graphvizTest.o graphvizTest.cpp 
/usr/include/boost/dynamic_property_map.hpp: In member function 
std::string boost::detail::dynamic_property_map_adaptor<PropertyMap>::get_string(const boost::any&) 
[with PropertyMap = 
boost::vec_adj_list_vertex_property_map< 
    boost::adjacency_list< 
    boost::vecS, boost::vecS, boost::directedS, 
    boost::no_property, boost::no_property, 
    boost::no_property, boost::listS 
    >, 
    boost::adjacency_list< 
    boost::vecS, boost::vecS, boost::directedS, boost::no_property, 
    boost::no_property, boost::no_property, boost::listS 
    >*, 
    boost::detail::error_property_not_found, 
    boost::detail::error_property_not_found&, 
    boost::vertex_name_t 
> 
]':  
graphvizTest.cpp:29: instantiated from here  
/usr/include/boost/dynamic_property_map.hpp:196: error: no match for 'operator<<' in 'out << boost::get 
[with 
PropertyMap = 
boost::vec_adj_list_vertex_property_map< 
    boost::adjacency_list< 
    boost::vecS, boost::vecS, boost::directedS, boost::no_property, boost::no_property, 
    boost::no_property, boost::listS 
    >, 
    boost::adjacency_list< 
    boost::vecS, boost::vecS, boost::directedS, boost::no_property, boost::no_property, 
    boost::no_property, boost::listS 
    >*, 
    boost::detail::error_property_not_found, 
    boost::detail::error_property_not_found&, 
    boost::vertex_name_t 
>, 
Reference = boost::detail::error_property_not_found&, K = long unsigned int 
] 

... 
+1

Vous n'avez pas inclus la ligne 29 de graphvizTest.cpp .... –

+0

J'ai nettoyé le code lorsque j'ai soumis la question et supprimé quelques lignes. La ligne qui provoque l'erreur est la seconde à partir de la dernière, l'appel à read_graphviz. –

Répondre

2

Il n'y a pas de propriété de nœud nommé name dans votre graphique, et ainsi la carte de la propriété que vous obtenez de get(boost::vertex_name, graph) est une erreur. Regardez la documentation pour savoir comment ajouter une propriété vertex pour boost::vertex_name (en utilisant des propriétés de style ancien) ou ajouter une propriété groupée pour représenter le nom et l'utiliser à la place de l'expression get dans votre objet dynamic_properties.

Questions connexes