kruskal_minimum_spanning_tree not working on filtered graph with weight map as named property
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 58/100
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện lỗi trình biên dịch từ ví dụ filtered_graph bằng cách sử dụng boost/graph/kruskal_minimum_spanning_tree.hpp, boost/graph/filtered_graph.hpp và function_property_map.hpp. So sánh lời gọi weight_map bị lỗi với workaround vertex_index_map được tài liệu hóa; công việc được xem là hoàn tất khi lời gọi trên đồ thị đã lọc biên dịch được mà không cần workaround đó và vẫn tạo ra cây khung mong đợi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi everyone,
i cant use kruskal's alg on a filtered graph with a weight_map as named property.
#include <boost/graph/adjacency_list.hpp>
#include "boost/graph/graph_utility.hpp"
#include <boost/graph/filtered_graph.hpp>
#include <boost/property_map/function_property_map.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
using Graph = boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS>;
using Vertex = boost::graph_traits<Graph>::vertex_descriptor;
using Edge = boost::graph_traits<Graph>::edge_descriptor;
int main()
{
Graph G;
// create a complete graph with 4 nodes.
for (int i = 0; i < 5 ; ++i)
{
for (int j = i+1; j< 5; ++j)
boost::add_edge(i, j, G);
}
boost::print_graph(G);
/* 0 <--> 1 2 3 4
1 <--> 0 2 3 4
2 <--> 0 1 3 4
3 <--> 0 1 2 4
4 <--> 0 1 2 3 */
struct Filter
{
bool operator()(Vertex const & v) const
{
if (v != 0 && v != 2)
return true;
return false;
}
};
boost::filtered_graph G_f(G, boost::keep_all(), Filter());
boost::print_graph(G_f);
/* 1 <--> 3 4
3 <--> 1 4
4 <--> 1 3 */
auto wmap = boost::make_function_property_map<Edge, double>([](Edge const & e){ return 1.0; });
std::vector<Edge> mst;
// Works:
kruskal_minimum_spanning_tree(G, std::back_inserter(mst), boost::weight_map(wmap));
// Does not compile:
kruskal_minimum_spanning_tree(G_f, std::back_inserter(mst), boost::weight_map(wmap));
double result = 0;
for (auto const & e : mst)
result += wmap[e];
std::cout << result << "\n"; // prints 4
}
Gives following errors:
error C2039: 'type': is not a member of 'boost::vertex_property_type<Graph>'
error C2039: [
error C2039: with
error C2039: Graph=boost::filtered_graph<Graph,boost::keep_all,main::Filter>
error C2039: ]
error C3203: 'type': unspecialized class template can't be used as a template argument for template parameter 'Property', expected a real type
Workaround:
kruskal_minimum_spanning_tree(G_f, std::back_inserter(mst), boost::weight_map(wmap).vertex_index_map(get(boost::vertex_index, G_f)));
More details on stackoverflow (Thanks to user sehe who helped me out):
https://stackoverflow.com/questions/78612600/boost-graph-using-kruskal-algorithm-on-filtered-graph-doesnt-compile
- Ngôn ngữ chính
- C++
- Star
- 402
- Fork
- 251
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 38
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của boostorg/graph
-
Good first issues: start contributing to Boost.Graph hereCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbeginner friendly
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
boostorg/graph#593 · 63 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
api data structure
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
Maintainer thường phản hồi trong vòng 1 ngày
-
CMake < 3.10 failsĐang mởinfra priority: high
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 45/100
boostorg/graph#688 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
Maintainer thường phản hồi trong vòng 1 ngày
-
algorithm
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của boostorg/graph
Issue tương tự
-
agent:WSL code-review linux pri:medium refactoring
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
kind/enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 82/100
psi29a/d2decomped#691 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
CachyOS/packageinstaller#144 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
(S1 - Need confirmation)
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
CleverRaven/Cataclysm-DDA#89715 ·
Maintainer thường phản hồi trong vòng 1 ngày