2013-08-19 25 views
2

我有一個自定義邊緣屬性(MyWeight)在增強圖中,並且想要應用Dijkstra最短路徑搜索。boost :: graph自定義權重類型:numeric_limits必要?

我的體重類型是,在boost :: operators的幫助下,可加,減,小於可比和平等可比。

因爲我知道搜索必須從某些東西開始,所以我需要相當於一個零,並找出一個節點是否可達,非常大。

MyWeight weight_zero(...), weight_inf(...); 

// now, weight_zero is less than all other weights, weight_inf greater than all other weights. 

boost::dijkstra_shortest_paths(G, target_idx, boost::predecessor_map(&predecessors[0]) 
    .distance_map(&distances[0]) 
    .distance_inf(weight_inf) 
    .distance_zero(weight_zero) 
      ); 

這是我使用我的自定義重量的原則。它編譯(和似乎正常工作)用gcc 4.8.1,但用gcc 4.7.3我得到以下錯誤(一點點縮短):

/usr/include/c++/4.7/limits:-1: In instantiation of 'static constexpr _Tp std::numeric_limits<_Tp>::max() [with _Tp = MyWeight<2, MyEvaluator>]': 
/usr/include/c++/4.7/limits:313: error: no matching function for call to 'MyWeight<2, MyEvaluator>::MyWeight(int)' 

MyWeight實際上是一個模板)

我將此消息解釋爲「您的類型沒有std :: numeric_limit」,另一方面,我告訴BGL要使用哪個極值,並且不明白它爲什麼會嘗試調用數值限制。我認爲最好的嘗試是讓numeric_limits識別我的自定義數據類型。

有人可以指出我如何做到這一點?

我發現第一個提示here,但該示例使用的成員像digitsdigits10,我想知道它們來自哪裏。

EDIT

This是像礦的例子。無法編譯它,錯誤見上文。

+0

如果還沒有,您可能需要[報告爲助推錯誤](http://www.boost.org/development/bugs.html)。 –

+0

我會這樣做的。我創建了一個拒絕編譯的示例程序,目前我無法使用另一個版本進行測試,但它是相同的方案。 – user4344

回答

1

這似乎是一個錯誤(或不足;我不確定它是否可修復)在命名參數包裝器中,即使它們未被使用也展開默認值。如果使用位置參數重載並手動填入所有參數,則不需要numeric_limits

相關問題