2011-06-21 13 views
0

ようこんにちは、私はブーストグラフを持っている:問題がエッジクラスの再帰的なテンプレートであるブーストグラフ再帰的なテンプレートの問題

struct Vertex; 
struct Edge; 



typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, Vertex, Edge> Graph_t; 


struct Vertex { 
}; 

struct Edge { 
    typedef std::vector<Graph_t::vertex_descriptor> intermediate_vertices_t; 
    intermediate_vertices_t intermediate_vertices; 
}; 

。私は頂点のベクトルを格納する必要があります。

+0

あなたは 'Graph_t'の権利のテンプレートパラメータを取得していますか? 4番目と5番目のパラメータは_properties_であり、頂点クラスとエッジクラスではありません...頂点コレクションとエッジコレクションに適切なコンテナを提供し、 'boost :: adjacency_list :: vertex_descriptor'はその値タイプコンテナ(多かれ少なかれ)。 –

+0

どのコンパイラを使用しますか?私は遵守し、問題なくVC++ 2010でコードを実行しました – Eugene

答えて

0

私のような小さなラッパークラスを使用して終了:

typedef Graph_t::vertex_descriptor vd_t;       

struct iVertexWrap{             
    iVertexWrap(vd_t v) : v(v) 
    {}                
    vd_t v; 
}; 

は前方エッジクラスの前にそれを宣言する。

2

adjacency_list_traitsを使用すると、この問題を回避できます。このクラスを使用すると、ユーザがグラフのプロパティタイプを指定しなくても、頂点およびエッジの記述子タイプにアクセスできます。

struct Vertex { 
}; 

typedef boost::adjacency_list_traits<boost::vecS, boost::vecS, boost::bidirectionalS>::vertex_descriptor VertexDescriptor; 
struct Edge { 
    typedef std::vector<VertexDescriptor> intermediate_vertices_t; 
    intermediate_vertices_t intermediate_vertices; 
}; 
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, Vertex, Edge> Graph_t; 
関連する問題