1919
2020namespace grt {
2121
22- void SparseGraph::init (GridGraphView<CostT>& wire_cost_view, SparseGrid& grid)
22+ void SparseGraph::init (const GridGraphView<CostT>& wire_cost_view,
23+ const SparseGrid& grid)
2324{
2425 // 0. Create pseudo pins
2526 robin_hood::unordered_map<uint64_t , std::pair<PointT, IntervalT>>
2627 selectedAccessPoints;
2728 grid_graph_->selectAccessPoints (net_, selectedAccessPoints);
2829 pseudo_pins_.reserve (selectedAccessPoints.size ());
29- for (auto & selectedPoint : selectedAccessPoints) {
30+ for (const auto & selectedPoint : selectedAccessPoints) {
3031 pseudo_pins_.push_back (selectedPoint.second );
3132 }
3233
@@ -46,9 +47,8 @@ void SparseGraph::init(GridGraphView<CostT>& wire_cost_view, SparseGrid& grid)
4647 const int ySize = grid_graph_->getSize (1 );
4748 xs_.reserve (xSize / grid.interval .x () + pxs.size ());
4849 ys_.reserve (ySize / grid.interval .y () + pys.size ());
49- int j = 0 ;
50- for (int i = 0 ; true ; i++) {
51- int x = i * grid.interval .x () + grid.offset .x ();
50+ for (int i = 0 , j = 0 ; true ; i++) {
51+ const int x = i * grid.interval .x () + grid.offset .x ();
5252 for (; j < pxs.size () && pxs[j] <= x; j++) {
5353 if ((!xs_.empty () && pxs[j] == xs_.back ()) || pxs[j] == x) {
5454 continue ;
@@ -61,9 +61,8 @@ void SparseGraph::init(GridGraphView<CostT>& wire_cost_view, SparseGrid& grid)
6161 break ;
6262 }
6363 }
64- j = 0 ;
65- for (int i = 0 ; true ; i++) {
66- int y = i * grid.interval .y () + grid.offset .y ();
64+ for (int i = 0 , j = 0 ; true ; i++) {
65+ const int y = i * grid.interval .y () + grid.offset .y ();
6766 for (; j < pys.size () && pys[j] <= y; j++) {
6867 if ((!ys_.empty () && pys[j] == ys_.back ()) || pys[j] == y) {
6968 continue ;
@@ -79,7 +78,7 @@ void SparseGraph::init(GridGraphView<CostT>& wire_cost_view, SparseGrid& grid)
7978
8079 // 2. Add vertices
8180 vertices_.reserve (2 * xs_.size () * ys_.size ());
82- for (unsigned direction = 0 ; direction < 2 ; direction++) {
81+ for (int direction = 0 ; direction < 2 ; direction++) {
8382 for (auto & y : ys_) {
8483 for (auto & x : xs_) {
8584 vertices_.emplace_back (direction, x, y);
@@ -94,15 +93,15 @@ void SparseGraph::init(GridGraphView<CostT>& wire_cost_view, SparseGrid& grid)
9493 = [&](const unsigned direction, const int xi, const int yi) {
9594 const int u = getVertexIndex (direction, xi, yi);
9695 const int v = direction == MetalLayer::H ? u + 1 : u + xs_.size ();
97- PointT U (xs_[xi], ys_[yi]);
98- PointT V (xs_[xi + 1 - direction], ys_[yi + direction]);
96+ const PointT U (xs_[xi], ys_[yi]);
97+ const PointT V (xs_[xi + 1 - direction], ys_[yi + direction]);
9998
10099 edges_[u][0 ] = v;
101100 edges_[v][1 ] = u;
102101 costs_[u][0 ] = costs_[v][1 ] = wire_cost_view.sum (U, V);
103102 };
104103
105- for (unsigned direction = 0 ; direction < 2 ; direction++) {
104+ for (int direction = 0 ; direction < 2 ; direction++) {
106105 if (direction == MetalLayer::H) {
107106 for (int yi = 0 ; yi < ys_.size (); yi++) {
108107 for (int xi = 0 ; xi + 1 < xs_.size (); xi++) {
@@ -207,12 +206,12 @@ void MazeRoute::run()
207206 continue ;
208207 }
209208 for (int edgeIndex = 0 ; edgeIndex < 3 ; edgeIndex++) {
210- int nextVertex = graph_.getNextVertex (solution->vertex , edgeIndex);
209+ const int nextVertex = graph_.getNextVertex (solution->vertex , edgeIndex);
211210 if (nextVertex == -1
212211 || (solution->prev && nextVertex == solution->prev ->vertex )) {
213212 continue ;
214213 }
215- CostT nextCost
214+ const CostT nextCost
216215 = solution->cost + graph_.getEdgeCost (solution->vertex , edgeIndex);
217216 if (nextCost < minCosts[nextVertex]) {
218217 updateSolution (
@@ -255,8 +254,8 @@ std::shared_ptr<SteinerTreeNode> MazeRoute::getSteinerTree() const
255254 while (temp) {
256255 auto it = created.find (temp->vertex );
257256 if (it == created.end ()) {
258- PointT point = graph_.getPoint (temp->vertex );
259- auto node = std::make_shared<SteinerTreeNode>(point);
257+ const PointT point = graph_.getPoint (temp->vertex );
258+ const auto node = std::make_shared<SteinerTreeNode>(point);
260259 created.emplace (temp->vertex , node);
261260 if (lastNode) {
262261 node->addChild (lastNode);
@@ -266,7 +265,7 @@ std::shared_ptr<SteinerTreeNode> MazeRoute::getSteinerTree() const
266265 }
267266 if (!lastNode || !temp->prev ) {
268267 // Both the start and the end of the path should contain pins
269- int pinIndex = graph_.getVertexPin (temp->vertex );
268+ const int pinIndex = graph_.getVertexPin (temp->vertex );
270269 assert (pinIndex != -1 );
271270 node->setFixedLayers (graph_.getPseudoPin (pinIndex).second );
272271 }
@@ -286,10 +285,10 @@ std::shared_ptr<SteinerTreeNode> MazeRoute::getSteinerTree() const
286285 tree, [&](const std::shared_ptr<SteinerTreeNode>& node) {
287286 for (int childIndex = 0 ; childIndex < node->getNumChildren ();
288287 childIndex++) {
289- std::shared_ptr<SteinerTreeNode> child
288+ const std::shared_ptr<SteinerTreeNode> child
290289 = node->getChildren ()[childIndex];
291290 if (node->x () == child->x () && node->y () == child->y ()) {
292- for (auto & gradchild : child->getChildren ()) {
291+ for (const auto & gradchild : child->getChildren ()) {
293292 node->addChild (gradchild);
294293 }
295294 if (child->getFixedLayers ().IsValid ()) {
@@ -309,7 +308,7 @@ std::shared_ptr<SteinerTreeNode> MazeRoute::getSteinerTree() const
309308 SteinerTreeNode::preorder (
310309 tree, [&](const std::shared_ptr<SteinerTreeNode>& node) {
311310 for (std::shared_ptr<SteinerTreeNode>& child : node->getChildren ()) {
312- unsigned direction
311+ const int direction
313312 = (node->y () == child->y () ? MetalLayer::H : MetalLayer::V);
314313 std::shared_ptr<SteinerTreeNode> temp = child;
315314 while (!temp->getFixedLayers ().IsValid ()
0 commit comments