smarter joinable algo

This commit is contained in:
ntr
2018-12-30 15:15:34 +11:00
parent 79f96a2ee0
commit 1f180402b3
4 changed files with 10 additions and 10 deletions
+3 -6
View File
@@ -208,11 +208,8 @@ pub fn node_joinable(graph: &ZoneGraph, target_index: NodeIndex) -> bool {
}
}
// now check the graph for connectedness
// get all the nodes that have been successfully completed
let mut filtered = graph.clone();
filtered.retain_nodes(|g, i| {
match g.node_weight(i) {
let success_indices = graph.node_indices().filter(|i| {
match graph.node_weight(*i) {
Some(encounter) => encounter.success,
None => panic!("no weight for {:?}", i),
}
@@ -221,7 +218,7 @@ pub fn node_joinable(graph: &ZoneGraph, target_index: NodeIndex) -> bool {
// if a node is a neighbour of that graph
// and hasn't been attempted
// it is joinable
for i in filtered.node_indices() {
for i in success_indices {
match graph.neighbors(i).find(|n| *n == target_index) {
Some(_n) => return true,
None => continue,