Grafo
Examplo: Aplicação do algoritmo de Bellman-Ford para uma edge_list. enum { u, v, x, y, z, N }; char name[] = { 'u', 'v', 'x', 'y', 'z' }; typedef std::pair<int,int> E; E edges[] = { E(u,y), E(u,x), E(u,v), E(v,u), E(x,y), E(x,v), E(y,v), E(y,z), E(z,u), E(z,x) }; int weight[] = { -4, 8, 5, -2, 9, -3, 7, 2, 6, 7 }; typedef boost::edge_list<E*> Graph; Graph g(edges, edges + sizeof(edges) / sizeof(E)); std::vector<int> distance(N, std::numeric_limits<short>::max()); std::vector<int> parent(N,-1); distance[z] = 0; parent[z] = z; bool r = boost::bellman_ford_shortest_paths(g, int(N), weight, distance.begin(), parent.begin()); if (r) for (int i = 0; i < N; ++i) std::cout << name[i] << ": "