KShortestPaths3.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // Created by wrede on 24.06.16.
  3. //
  4. #ifndef GBMOT_KSHORTESTPATHS3_H
  5. #define GBMOT_KSHORTESTPATHS3_H
  6. #include "../graph/Definitions.h"
  7. namespace algo
  8. {
  9. class KShortestPaths3
  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. MultiPredecessorMap MapPathToOrig(size_t iteration);
  30. double PathCosts(size_t iteration);
  31. void QueueCopyEdges();
  32. void ClearAllEdges();
  33. void QueueRemoveEdge(Vertex source, Vertex target);
  34. void QueueAddEdge(Vertex source, Vertex target, double weight);
  35. void UpdateEdges();
  36. public:
  37. KShortestPaths3();
  38. ~KShortestPaths3();
  39. MultiPredecessorMap Run(DirectedGraph& graph_orig,
  40. Vertex source, Vertex sink,
  41. size_t iterations);
  42. };
  43. }
  44. #endif //GBMOT_KSHORTESTPATHS3_H