now RRGraph is proven to be correct as rr_node in terms of XML output

This commit is contained in:
tangxifan 2020-01-31 17:27:18 -07:00
parent 5006a4395d
commit 5e2559dc14
2 changed files with 15 additions and 9 deletions

View File

@ -1120,19 +1120,23 @@ void RRGraph::rebuild_node_edges() {
auto is_incoming_edge = [&](const RREdgeId edge) {
return edge_sink_node(edge) == node;
};
std::partition(node_edges_[node].get(),
node_edges_[node].get() + node_num_in_edges_[node] + node_num_out_edges_[node],
is_incoming_edge);
/* Use stable_partition to keep the relative order,
* This is mainly for comparing the RRGraph write with rr_node writer
* so that it is easy to check consistency
*/
std::stable_partition(node_edges_[node].get(),
node_edges_[node].get() + node_num_in_edges_[node] + node_num_out_edges_[node],
is_incoming_edge);
//Partition incoming by configurable/non-configurable
std::partition(node_edges_[node].get(),
node_edges_[node].get() + node_num_in_edges_[node],
is_configurable_edge);
std::stable_partition(node_edges_[node].get(),
node_edges_[node].get() + node_num_in_edges_[node],
is_configurable_edge);
//Partition outgoing by configurable/non-configurable
std::partition(node_edges_[node].get() + node_num_in_edges_[node],
node_edges_[node].get() + node_num_in_edges_[node] + node_num_out_edges_[node],
is_configurable_edge);
std::stable_partition(node_edges_[node].get() + node_num_in_edges_[node],
node_edges_[node].get() + node_num_in_edges_[node] + node_num_out_edges_[node],
is_configurable_edge);
#if 0
//TODO: Sanity check remove!

View File

@ -172,6 +172,8 @@ void write_rr_graph_edges(fstream &fp, const RRGraph& rr_graph) {
fp << "\t<rr_edges>" << endl;
for (auto node : rr_graph.nodes()) {
/* Sort the edges by the ids of sink nodes */
std::vector<RREdgeId> sorted_out_edge_ids;
for (auto edge: rr_graph.node_out_edges(node)) {
fp << "\t\t<edge src_node=\"" << rr_graph.node_index(node) <<
"\" sink_node=\"" << rr_graph.node_index(rr_graph.edge_sink_node(edge)) <<