From 0dbfc6eaefbb74850b401cdf1c5c9c37dc02ad74 Mon Sep 17 00:00:00 2001 From: Bruno Donassolo Date: Tue, 13 Apr 2021 17:24:11 +0200 Subject: [PATCH] StarZone: implement get_graph method Add get_graph for StarZone. A top node named with the zone's name is created to be the center of the star. --- src/kernel/routing/StarZone.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/kernel/routing/StarZone.cpp b/src/kernel/routing/StarZone.cpp index 972da4e063..57a2c8c719 100644 --- a/src/kernel/routing/StarZone.cpp +++ b/src/kernel/routing/StarZone.cpp @@ -61,6 +61,27 @@ void StarZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* void StarZone::get_graph(const s_xbt_graph_t* graph, std::map>* nodes, std::map>* edges) { + xbt_node_t star_node = new_xbt_graph_node(graph, get_cname(), nodes); + + for (auto const& src : get_vertices()) { + /* going up */ + xbt_node_t src_node = new_xbt_graph_node(graph, src->get_cname(), nodes); + xbt_node_t previous = src_node; + for (auto* link : links_up_[src->id()]) { + xbt_node_t current = new_xbt_graph_node(graph, link->get_cname(), nodes); + new_xbt_graph_edge(graph, previous, current, edges); + previous = current; + } + new_xbt_graph_edge(graph, previous, star_node, edges); + /* going down */ + previous = star_node; + for (auto* link : links_down_[src->id()]) { + xbt_node_t current = new_xbt_graph_node(graph, link->get_cname(), nodes); + new_xbt_graph_edge(graph, previous, current, edges); + previous = current; + } + new_xbt_graph_edge(graph, previous, src_node, edges); + } } void StarZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, -- 2.20.1