KShortestPaths4.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // Created by wrede on 24.06.16.
  3. //
  4. #ifndef GBMOT_KSHORTESTPATHS4_H
  5. #define GBMOT_KSHORTESTPATHS4_H
  6. #include "../graph/Definitions.h"
  7. namespace algo
  8. {
  9. class KShortestPaths4
  10. {
  11. private:
  12. DirectedGraph graph_;
  13. Vertex source_;
  14. Vertex sink_;
  15. VertexDistanceMap vertex_labels_;
  16. VertexDistanceMap vertex_distances_;
  17. std::vector<Vertex> vertex_candidates_;
  18. VertexPredecessorMap interlacing_predecessors_;
  19. std::unordered_map<Vertex, bool> interlacing_predecessors_positive_;
  20. std::vector<Vertex> source_neighbors_;
  21. std::vector<Vertex> sink_neighbors_;
  22. VertexPredecessorMap path_predecessors_;
  23. size_t max_paths_count_;
  24. size_t total_paths_count_;
  25. double total_paths_distance_;
  26. void Initialization();
  27. void InterlacingConstruction();
  28. void NeighborDistanceTest(Vertex r);
  29. void NegativeInterlacing(Vertex vertex_i);
  30. void NextPathDefinition();
  31. void NewInitialConditions();
  32. void FeasibleTermination();
  33. void NonFeasibleTermination();
  34. void SetCandidates();
  35. Vertex FindPathDestination(VertexPredecessorMap& map, Vertex origin,
  36. std::vector<Vertex>& possible_destination, Vertex element);
  37. Vertex FindPathSuccessor(VertexPredecessorMap& map, Vertex origin, Vertex destination, Vertex element);
  38. bool Remove(std::vector<Vertex>& vector, Vertex element);
  39. bool Contains(VertexPredecessorMap& map, Vertex origin, Vertex destination, Vertex element);
  40. bool Contains(std::vector<Vertex>& vector, Vertex element);
  41. public:
  42. KShortestPaths4(DirectedGraph graph, Vertex source, Vertex sink, size_t max_paths_count);
  43. void Run();
  44. std::vector<std::vector<Vertex>> GetPaths();
  45. double GetTotalPathsLength();
  46. };
  47. }
  48. #endif //GBMOT_KSHORTESTPATHS4_H