计算最短路径数BOOST图c ++

时间:2018-11-26 18:33:59

标签: c++ boost graph

我正在尝试获取从点1到7的最短路径数。

我知道BOOST c ++库中有很多方法,例如kruskal,dijkstra,r_c_shortest_path或只是dfs / bfs。...

问题是我了解所有这些方法仅返回一种方法。

有某种方法可以拉开所有不同的路径以从一个点到达另一个点?

例如,我有这个:

   

#include <boost/config.hpp> #include <boost/graph/adjacency_list.hpp> using namespace boost; #include <iostream> using namespace std; int main(int, char*[]) { typedef adjacency_list<> Graph ; Graph g(10); typedef std::pair<int, int> E; const int num_nodes = 7; E edge_array[] = { E(1, 2), E(1, 3), E(2, 4), E(3, 4), E(2, 5), E(4, 5), E(4, 7), E(4, 6), E(5,7), E(6,7) }; int weights[] = { 5,7,10,8,30,12,25,11,13,30 }; boost::graph_traits<Graph>::vertex_descriptor vd, vd2; typedef typename boost::graph_traits<Graph>::edge_descriptor e; std::pair<e, bool> p[10]; for (int i = 0; i < 10; ++i) { vd = edge_array[i].first; vd2 = edge_array[i].second; p[i] = add_edge(vd, vd2, g); } graph_traits<Graph>::vertex_descriptor s = source(p[0].first,g); graph_traits<Graph>::vertex_descriptor t = target(p[9].first,g); //And now here i need to save all the posible shortest paths using: //kruskal template <class Graph, class OutputIterator, class P, class T, class R> OutputIterator kruskal_minimum_spanning_tree(Graph& g, OutputIterator tree_edges, const bgl_named_params<P, T, R>& params = all defaults); // dijkstra template <typename Graph, typename P, typename T, typename R> void dijkstra_shortest_paths(Graph& g, typename graph_traits<Graph>::vertex_descriptor s, const bgl_named_params<P, T, R>& params); //r_c_shortest_paths r_c_shortest_paths( g, vertex_index_map, edge_index_map, s, t, pareto_optimal_solutions, pareto_optimal_resource_containers, rc, ref, dominance, la, vis ) return 0; }

摘要:不知道如何获取所有最短路径并将其保存以进行比较

我转到这里是因为几个小时后无法取出

谢谢你,问候和抱歉我的英语不好

0 个答案:

没有答案