smarter joinable algo
This commit is contained in:
+3
-6
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user