1

みんな。私は BOOST GRAPH LIBRARY の初心者です。チーム内の関係を表す試行グラフを作成しようとしましたが、うまくいきませんでした。コードは次のとおりです。

 // Construct a graph that shows relationship in Edexteam

#include<iostream>
#include<utility>
#include<fstream>
#include<boost/graph/graph_traits.hpp>
#include<boost/graph/adjacency_list.hpp>

using namespace std;
using namespace boost;

int main(){
   // Construct data about our graph

   enum Edexteam {ProfNachiket, Lam, Son, Shubham, Girl1, Girl2, Num};

   const int num_members = Num;

   const char* name[] = {"Prof Nachiket", "Lam", "Son", "Shubham","Girl1","Girl2   "};

   // Configure some general characteristics for our graph

   typedef adjacency_list<vecS,vecS,bidirectionalS> EdexteamGraph;

   // Construct edges

   typedef pair<int,int> RelationInEdexteam;


   RelationInEdexteam relation[] = {RelationInEdexteam(Lam,Son),RelationInEdexteam(ProfNachiket,Son),
                                    RelationInEdexteam(Girl1,Girl2),RelationInEdexteam(ProfNachiket,Shubham)};

   // Construct graph by using edge iterator constructor

   EdexteamGraph graph(relation, relation + sizeof(relation) / sizeof(RelationInEdexteam), num_members);

  // Get the property map for vertex indices

   typedef property_map<EdexteamGraph,vertex_index_t> VerIndex;

   VerIndex index = get(vertex_index,graph);
   cout << "vertices(graph) = ";
   typedef graph_traits<EdexteamGraph>::vertex_iterator vertex_iter;
   pair<vertex_iter, vertex_iter> vp;
   for (vp = vertices(graph); vp.first != vp.second; ++vp.first)
     std::cout << index[*vp.first] <<  " ";
   std::cout << std::endl;

   return 0;

}

そして、エラーメッセージが表示されました

trygraph.cpp: In function ‘int main()’:
trygraph.cpp:41:43: error: conversion from ‘boost::property_map<boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS>, boost::vertex_index_t>::type {aka boost::vec_adj_list_vertex_id_map<boost::no_property, long unsigned int>}’ to non-scalar type ‘VerIndex {aka boost::property_map<boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS>, boost::vertex_index_t>}’ requested
trygraph.cpp:46:34: error: no match for ‘operator[]’ in ‘index[((boost::iterator_facade<boost::range_detail::integer_iterator<long unsigned int>, long unsigned int, boost::random_access_traversal_tag, long unsigned int, long int>*)(& vp.std::pair<boost::range_detail::integer_iterator<long unsigned int>, boost::range_detail::integer_iterator<long unsigned int> >::first))->boost::iterator_facade<I, V, TC, R, D>::operator* [with Derived = boost::range_detail::integer_iterator<long unsigned int>, Value = long unsigned int, CategoryOrTraversal = boost::random_access_traversal_tag, Reference = long unsigned int, Difference = long int, boost::iterator_facade<I, V, TC, R, D>::reference = long unsigned int]()]’

何が起こっていたのかよくわかりません。私がそれを指摘するのを手伝ってください。私は実際にそれを感謝します

4

0 に答える 0