Я пытаюсь получить число кратчайших путей от точек 1 до 7.
Я знаю, что в библиотеке BOOST c ++ есть много методов, таких как kruskal, dijkstra, r_c_shortest_path или просто dfs / bfs....
Проблема в том, что я понимаю, что все эти методы возвращают только 1 путь.
есть какой-то метод, который тянет все различные пути, чтобы добраться из одной точки в другую?
Например, у меня есть это:
</p>
<code>#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;
}
</code>
Резюме: не знаю, как получить все кратчайшие пути и сохранить его для сравнения
Я перехожу сюда, потому что не могу вытащить его через несколько часов
спасибо, привет и извините за мой плохой английский