KShortestPaths2.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // Created by wrede on 15.06.16.
  3. //
  4. #ifndef GBMOT_KSHORTESTPATHS2_H
  5. #define GBMOT_KSHORTESTPATHS2_H
  6. #include "../graph/Definitions.h"
  7. namespace algo
  8. {
  9. class KShortestPaths2
  10. {
  11. private:
  12. DirectedGraph graph_orig_;
  13. DirectedGraph graph_copy_;
  14. Vertex source_;
  15. Vertex sink_;
  16. std::unordered_map<Vertex, Vertex> orig_to_copy_;
  17. std::unordered_map<Vertex, Vertex> copy_to_orig_;
  18. std::unordered_map<Vertex, Vertex> in_to_out_;
  19. std::unordered_map<Vertex, Vertex> out_to_in_;
  20. std::vector<std::pair<std::pair<Vertex, Vertex>, double>> edges_to_add_;
  21. std::vector<std::pair<Vertex, Vertex>> edges_to_remove_;
  22. std::vector<std::unordered_map<Vertex, double>> i_distances_;
  23. std::vector<MultiPredecessorMap> i_paths_;
  24. void CreateCopy();
  25. void ExtendGraph(size_t iteration);
  26. void TransformEdges(size_t iteration);
  27. void FindAndAugment(size_t iteration);
  28. void Interlace(size_t iteration);
  29. double PathCosts(size_t iteration);
  30. void QueueCopyEdges();
  31. void QueueRemoveAll();
  32. void QueueRemoveEdge(Vertex source, Vertex target);
  33. void QueueAddEdge(Vertex source, Vertex target, double weight);
  34. void UpdateEdges();
  35. public:
  36. KShortestPaths2();
  37. ~KShortestPaths2();
  38. MultiPredecessorMap Run(DirectedGraph& graph_orig,
  39. Vertex source, Vertex sink,
  40. size_t iterations);
  41. };
  42. }
  43. #endif //GBMOT_KSHORTESTPATHS2_H