1 /* Copyright (c) 2013-2016. 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 "src/kernel/routing/RoutedZone.hpp"
11 typedef struct graph_node_data {
13 int graph_id; /* used for caching internal graph id's */
14 } s_graph_node_data_t;
15 typedef s_graph_node_data_t* graph_node_data_t;
17 typedef struct graph_node_map_element {
19 } s_graph_node_map_element_t;
20 typedef s_graph_node_map_element_t* graph_node_map_element_t;
22 typedef struct route_cache_element {
25 } s_route_cache_element_t;
26 typedef s_route_cache_element_t* route_cache_element_t;
36 /** @ingroup ROUTING_API
37 * @brief NetZone with an explicit routing computed on need with Dijsktra
39 * The path between components is computed each time you request it,
40 * using the Dijkstra algorithm. A cache can be used to reduce the computation.
42 * This result in rather small platform file, very fast initialization, and very low memory requirements, but somehow long path resolution times.
44 class XBT_PRIVATE DijkstraZone : public RoutedZone {
46 DijkstraZone(NetZone* father, const char* name, bool cached);
49 ~DijkstraZone() override;
50 xbt_node_t routeGraphNewNode(int id, int graph_id);
51 graph_node_map_element_t nodeMapSearch(int id);
52 void newRoute(int src_id, int dst_id, sg_platf_route_cbarg_t e_route);
53 /* For each vertex (node) already in the graph,
54 * make sure it also has a loopback link; this loopback
55 * can potentially already be in the graph, and in that
56 * case nothing will be done.
58 * If no loopback is specified for a node, we will use
59 * the loopback that is provided by the routing platform.
61 * After this function returns, any node in the graph
62 * will have a loopback attached to it.
64 void getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_t route, double* lat) override;
65 void addRoute(sg_platf_route_cbarg_t route) override;
67 xbt_graph_t routeGraph_ = nullptr; /* xbt_graph */
68 xbt_dict_t graphNodeMap_ = nullptr; /* map */
69 xbt_dict_t routeCache_ = nullptr; /* use in cache mode */
75 #endif /* SURF_ROUTING_DIJKSTRA_HPP_ */