data->graph_id = graph_id;
xbt_node_t node = xbt_graph_new_node(routeGraph_, data);
- graph_node_map_element_t elm = new s_graph_node_map_element_t;
- elm->node = node;
- graphNodeMap_.insert({id, elm});
+ graphNodeMap_.emplace(id, node);
return node;
}
-graph_node_map_element_t DijkstraZone::nodeMapSearch(int id)
+xbt_node_t DijkstraZone::nodeMapSearch(int id)
{
auto ret = graphNodeMap_.find(id);
return ret == graphNodeMap_.end() ? nullptr : ret->second;
xbt_node_t src = nullptr;
xbt_node_t dst = nullptr;
- graph_node_map_element_t src_elm = nodeMapSearch(src_id);
- graph_node_map_element_t dst_elm = nodeMapSearch(dst_id);
+ xbt_node_t src_elm = nodeMapSearch(src_id);
+ xbt_node_t dst_elm = nodeMapSearch(dst_id);
if (src_elm)
- src = src_elm->node;
+ src = src_elm;
if (dst_elm)
- dst = dst_elm->node;
+ dst = dst_elm;
/* add nodes if they don't exist in the graph */
if (src_id == dst_id && src == nullptr && dst == nullptr) {
xbt_dynar_t nodes = xbt_graph_get_nodes(routeGraph_);
/* Use the graph_node id mapping set to quickly find the nodes */
- graph_node_map_element_t src_elm = nodeMapSearch(src_id);
- graph_node_map_element_t dst_elm = nodeMapSearch(dst_id);
+ xbt_node_t src_elm = nodeMapSearch(src_id);
+ xbt_node_t dst_elm = nodeMapSearch(dst_id);
- int src_node_id = static_cast<graph_node_data_t>(xbt_graph_node_get_data(src_elm->node))->graph_id;
- int dst_node_id = static_cast<graph_node_data_t>(xbt_graph_node_get_data(dst_elm->node))->graph_id;
+ int src_node_id = static_cast<graph_node_data_t>(xbt_graph_node_get_data(src_elm))->graph_id;
+ int dst_node_id = static_cast<graph_node_data_t>(xbt_graph_node_get_data(dst_elm))->graph_id;
/* if the src and dst are the same */
if (src_node_id == dst_node_id) {
};
typedef s_graph_node_data_t* graph_node_data_t;
-struct s_graph_node_map_element_t {
- xbt_node_t node;
-};
-typedef s_graph_node_map_element_t* graph_node_map_element_t;
-
struct s_route_cache_element_t {
int* pred_arr;
int size;
~DijkstraZone() override;
xbt_node_t routeGraphNewNode(int id, int graph_id);
- graph_node_map_element_t nodeMapSearch(int id);
+ xbt_node_t nodeMapSearch(int id);
void newRoute(int src_id, int dst_id, sg_platf_route_cbarg_t e_route);
/* For each vertex (node) already in the graph,
* make sure it also has a loopback link; this loopback
void addRoute(sg_platf_route_cbarg_t route) override;
xbt_graph_t routeGraph_ = nullptr; /* xbt_graph */
- std::map<int, graph_node_map_element_t> graphNodeMap_; /* map */
+ std::map<int, xbt_node_t> graphNodeMap_; /* map */
std::map<int, route_cache_element_t> routeCache_; /* use in cache mode */
};
}