Skip to content

Commit

Permalink
Add stall on demand, but no real speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
easbar committed Apr 2, 2020
1 parent c49e732 commit 94c01eb
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/path_calculator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ impl PathCalculator {
if curr.weight > best_weight {
break;
}
// stall on demand optimization
if self.is_stallable_fwd(graph, curr) {
continue;
}
let begin = graph.begin_out_edges(curr.node_id);
let end = graph.end_out_edges(curr.node_id);
for edge_id in begin..end {
Expand Down Expand Up @@ -128,6 +132,10 @@ impl PathCalculator {
if curr.weight > best_weight {
break;
}
// stall on demand optimization
if self.is_stallable_bwd(graph, curr) {
continue;
}
let begin = graph.begin_in_edges(curr.node_id);
let end = graph.end_in_edges(curr.node_id);
for edge_id in begin..end {
Expand Down Expand Up @@ -158,6 +166,34 @@ impl PathCalculator {
}
}

fn is_stallable_fwd(&self, graph: &FastGraph, curr: HeapItem) -> bool {
let begin = graph.begin_in_edges(curr.node_id);
let end = graph.end_in_edges(curr.node_id);
for edge_id in begin..end {
let adj = graph.edges_bwd[edge_id].adj_node;
let edge_weight = graph.edges_bwd[edge_id].weight;
let adj_weight = self.get_weight_fwd(adj);
if adj_weight != WEIGHT_MAX && adj_weight + edge_weight < curr.weight {
return true;
}
}
return false;
}

fn is_stallable_bwd(&self, graph: &FastGraph, curr: HeapItem) -> bool {
let begin = graph.begin_out_edges(curr.node_id);
let end = graph.end_out_edges(curr.node_id);
for edge_id in begin..end {
let adj = graph.edges_fwd[edge_id].adj_node;
let edge_weight = graph.edges_fwd[edge_id].weight;
let adj_weight = self.get_weight_bwd(adj);
if adj_weight != WEIGHT_MAX && adj_weight + edge_weight < curr.weight {
return true;
}
}
return false;
}

fn extract_nodes(
&self,
graph: &FastGraph,
Expand Down

0 comments on commit 94c01eb

Please sign in to comment.