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;
};

問題は、Edgeクラスの再帰テンプレートにあります。頂点のベクトルを保存する必要があります。

4

3 に答える 3

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;
于 2012-05-17T21:22:09.783 に答える
0

を使用してみてくださいadjacency_list:

http://www.boost.org/doc/libs/1_36_0/libs/graph/doc/adjacency_list.html

于 2011-06-28T17:09:28.043 に答える
0

私は最終的に次のような小さなラッパークラスを使用しました:

typedef Graph_t::vertex_descriptor vd_t;                           

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

Edge クラスの前に宣言します。

于 2011-07-05T14:35:28.753 に答える