Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/mwapl/simgrid
[simgrid.git] / include / simgrid / kernel / routing / FloydZone.hpp
1 /* Copyright (c) 2013-2023. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SIMGRID_ROUTING_FLOYD_HPP_
7 #define SIMGRID_ROUTING_FLOYD_HPP_
8
9 #include <simgrid/kernel/routing/RoutedZone.hpp>
10
11 namespace simgrid::kernel::routing {
12
13 /** @ingroup ROUTING_API
14  *  @brief NetZone with an explicit routing computed at initialization with Floyd-Warshal
15  *
16  *  The path between components is computed at creation time from every one-hop links,
17  *  using the Floyd-Warshal algorithm.
18  *
19  *  This result in rather small platform file, slow initialization time,  and intermediate memory requirements
20  *  (somewhere between the one of @{DijkstraZone} and the one of @{FullZone}).
21  */
22 class XBT_PRIVATE FloydZone : public RoutedZone {
23   /* vars to compute the Floyd algorithm. */
24   std::vector<std::vector<long>> predecessor_table_;
25   std::vector<std::vector<unsigned long>> cost_table_;
26   std::vector<std::vector<std::unique_ptr<Route>>> link_table_;
27
28   void init_tables(unsigned int table_size);
29   void do_seal() override;
30
31 public:
32   using RoutedZone::RoutedZone;
33   FloydZone(const FloydZone&) = delete;
34   FloydZone& operator=(const FloydZone&) = delete;
35
36   void get_local_route(const NetPoint* src, const NetPoint* dst, Route* into, double* latency) override;
37   void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
38                  const std::vector<s4u::LinkInRoute>& link_list, bool symmetrical) override;
39 };
40 } // namespace simgrid::kernel::routing
41
42 #endif /* SIMGRID_ROUTING_FLOYD_HPP_ */