fix: skip vertices to invalid nodes

This commit is contained in:
əlemi 2023-10-03 03:57:23 +02:00
parent 5adeda80ca
commit 92b2075c9d
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -44,15 +44,23 @@ impl MapCollector {
for vertex in vertices_domains {
let from = {
let node = nodes_map.get_mut(&vertex.from).expect("vertex from non existing node");
node.value += 1;
node.id
if let Some(node) = nodes_map.get_mut(&vertex.from) {
node.value += 1;
node.id
} else {
tracing::warn!("vertex from nonexisting node {}", vertex.from);
continue;
}
};
let to = {
let node = nodes_map.get_mut(&vertex.to).expect("vertex to non existing node");
node.value += 5;
node.id
if let Some(node) = nodes_map.get_mut(&vertex.to) {
node.value += 5;
node.id
} else {
tracing::warn!("vertex to nonexisting node {}", vertex.to);
continue;
}
};
vertices.push(Vertex { from, to });