1 /* Copyright (c) 2013-2018. The SimGrid Team. All rights reserved. */
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. */
6 #ifndef SURF_ROUTING_DIJKSTRA_HPP_
7 #define SURF_ROUTING_DIJKSTRA_HPP_
9 #include <simgrid/kernel/routing/RoutedZone.hpp>
11 struct s_graph_node_data_t {
13 int graph_id; /* used for caching internal graph id's */
15 typedef s_graph_node_data_t* graph_node_data_t;
25 /** @ingroup ROUTING_API
26 * @brief NetZone with an explicit routing computed on need with Dijsktra
28 * The path between components is computed each time you request it,
29 * using the Dijkstra algorithm. A cache can be used to reduce the computation.
31 * This result in rather small platform file, very fast initialization, and very low memory requirements, but somehow
32 * long path resolution times.
34 class XBT_PRIVATE DijkstraZone : public RoutedZone {
36 DijkstraZone(NetZone* father, std::string name, bool cached);
39 ~DijkstraZone() override;
40 xbt_node_t routeGraphNewNode(int id, int graph_id);
41 xbt_node_t nodeMapSearch(int id);
42 void newRoute(int src_id, int dst_id, RouteCreationArgs* e_route);
43 /* For each vertex (node) already in the graph,
44 * make sure it also has a loopback link; this loopback
45 * can potentially already be in the graph, and in that
46 * case nothing will be done.
48 * If no loopback is specified for a node, we will use
49 * the loopback that is provided by the routing platform.
51 * After this function returns, any node in the graph
52 * will have a loopback attached to it.
54 void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat) override;
55 void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
56 std::vector<simgrid::surf::LinkImpl*>& link_list, bool symmetrical) override;
58 xbt_graph_t route_graph_ = nullptr; /* xbt_graph */
59 std::map<int, xbt_node_t> graph_node_map_; /* map */
60 bool cached_; /* cache mode */
61 std::map<int, std::vector<int>> route_cache_; /* use in cache mode */
63 } // namespace routing
65 } // namespace simgrid
67 #endif /* SURF_ROUTING_DIJKSTRA_HPP_ */