2013-11-28 44 views
0

我正在使用Qt 4.8和minGW編譯器,其boost 1.46.0爲我的項目,但現在我已經轉移到Qt 5.0.2和MinGW編譯器與Boost 1.55.0 ,但是子圖的拷貝構造函數工作不正常。它不會爲頂點添加頂點(如果執行調試,則在頂點列表中顯示0個項目)。Boost Subgraph Copy構造函數不能與Qt 5.0.2和MinGW工作

typedef boost::adjacency_list< boost::listS, 
boost::vecS, 
boost::bidirectionalS, 
boost::property<boost::vertex_index_t, int , 
    property<vertex_position_t, point, VertexProperties> > , 
boost::property<boost::edge_index_t,int , EdgeProperties>, 
boost::property<graph_custom_prop_t,GraphProperties> > 
Graph; 
typedef boost::subgraph<Graph> SubGraph; 

我正在投入gMainGraph,我需要把它複製到m_gMainGraph

SubGraph* m_gMainGraph; 
m_gMainGraph = new SubGraph(gMainGraph); 
越來越創建

子圖,但沒有得到創建子圖內的頂點和邊緣,越來越只增加了最頂級的父圖。 在上面的代碼中,gMainGraph沒有被深度複製到m_gMainGraph中。

回答

0

這是一些解決此問題的方法,因爲子圖複製構造函數未實現在boost 1_55_0中執行​​深度複製。 我試過更新boost子圖複製構造函數。只需在你的boost的subgraph.hpp文件中使用下面的代碼。您需要評論一些來自1.52.0的代碼並使用以下更改。

// copy constructor 
/*Updated the copy constructor to work properly 
    As it's working in 1.46.0 and not in 1.52.0, In 1.52.0, the subgraph constructor is not itrating the child of child subgraphs 
    So only the direct children of main subgraph was getting copied*/ 
subgraph(const subgraph& x) 
    : m_graph(x.m_graph), m_parent(x.m_parent), m_edge_counter(x.m_edge_counter) //Added m_graph(x.m_graph) 
    , m_global_vertex(x.m_global_vertex), m_global_edge(x.m_global_edge) 
{ 
    // This loop belongs to 1.46.0 
    for(typename ChildrenList::const_iterator i = x.m_children.begin(); 
     i != x.m_children.end(); ++i) 
    { 
     m_children.push_back(new subgraph<Graph>(**i)); 
    } 
    /* 1.52.0 code*/ 

    //  if(x.is_root()) 
    //  { 
    //   m_graph = x.m_graph; 
    //  } 
    //  // Do a deep copy (recursive). 
    //  // Only the root graph is copied, the subgraphs contain 
    //  // only references to the global vertices they own. 
    //  typename subgraph<Graph>::children_iterator i,i_end; 
    //  boost::tie(i,i_end) = x.children(); 
    //  for(; i != i_end; ++i) 
    //  { 
    //   subgraph<Graph> child = this->create_subgraph(); 
    //   child = *i; 
    //   vertex_iterator vi,vi_end; 
    //   boost::tie(vi,vi_end) = vertices(*i); 
    //   for (;vi!=vi_end;++vi) 
    //   { 
    //   add_vertex(*vi,child); 
    //   } 
    //  } 
}