| 14 | { |
| 15 | |
| 16 | void insertEdge(RestrictionGraph &rg, const RestrictionID id, const RestrictionEdge &edge) |
| 17 | { |
| 18 | const auto range = rg.GetEdges(id); |
| 19 | auto &node = rg.nodes[id]; |
| 20 | if (node.edges_begin_idx + range.size() != rg.edges.size()) |
| 21 | { |
| 22 | // Most nodes will only have one edge, so this copy will be infrequent |
| 23 | node.edges_begin_idx = rg.edges.size(); |
| 24 | std::copy(range.begin(), range.end(), std::back_inserter(rg.edges)); |
| 25 | } |
| 26 | rg.edges.push_back(edge); |
| 27 | node.num_edges += 1; |
| 28 | } |
| 29 | |
| 30 | void insertRestriction(RestrictionGraph &rg, |
| 31 | const RestrictionID id, |