KShortestPaths4.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #include "../core/Tracklet.h"
  8. namespace algo
  9. {
  10. class KShortestPaths4
  11. {
  12. private:
  13. DirectedGraph graph_;
  14. Vertex source_;
  15. Vertex sink_;
  16. VertexDistanceMap vertex_labels_;
  17. VertexDistanceMap vertex_distances_;
  18. std::vector<Vertex> vertex_candidates_;
  19. VertexPredecessorMap interlacing_predecessors_;
  20. std::unordered_map<Vertex, bool> interlacing_predecessors_positive_;
  21. std::vector<Vertex> source_neighbors_;
  22. std::vector<Vertex> sink_neighbors_;
  23. VertexPredecessorMap path_predecessors_;
  24. size_t max_paths_count_;
  25. size_t total_paths_count_;
  26. double total_paths_distance_;
  27. EdgeWeightMap original_weights_;
  28. void Initialization();
  29. void InterlacingConstruction();
  30. void NeighborDistanceTest(Vertex vertex_r);
  31. void NegativeInterlacing(Vertex vertex_i);
  32. void NextPathDefinition();
  33. void NewInitialConditions();
  34. void FeasibleTermination();
  35. void NonFeasibleTermination();
  36. void SetCandidates();
  37. Vertex FindPathDestination(VertexPredecessorMap& map, Vertex origin,
  38. std::vector<Vertex>& possible_destination, Vertex element);
  39. Vertex FindPathSuccessor(VertexPredecessorMap& map, Vertex origin, Vertex destination, Vertex element);
  40. bool Remove(std::vector<Vertex>& vector, Vertex element);
  41. bool Contains(VertexPredecessorMap& map, Vertex origin, Vertex destination, Vertex element);
  42. bool Contains(std::vector<Vertex>& vector, Vertex element);
  43. public:
  44. KShortestPaths4(DirectedGraph graph, Vertex source, Vertex sink, size_t max_paths_count);
  45. void Run();
  46. std::vector<std::vector<Vertex>> GetPaths();
  47. void GetTracks(std::vector<core::TrackletPtr>& tracks);
  48. double GetTotalPathsLength();
  49. };
  50. }
  51. #endif //GBMOT_KSHORTESTPATHS4_H