Set the surrogate for a node, identified by its user-visible name. Call once per node after `add_edge` / `add_edge_weighted` has allocated a CSR-local id for it. If the node is not yet interned this is a no-op (the edge insertion that follows will intern it and a subsequent call with the correct surrogate will set it). Calling with `Surrogate::ZERO` is a no-op — the zero sentinel is the initial s
(&mut self, node: &str, surrogate: nodedb_types::Surrogate)
| 78 | /// with the correct surrogate will set it). Calling with `Surrogate::ZERO` |
| 79 | /// is a no-op — the zero sentinel is the initial state and has no meaning. |
| 80 | pub fn set_node_surrogate(&mut self, node: &str, surrogate: nodedb_types::Surrogate) { |
| 81 | let raw = surrogate.as_u32(); |
| 82 | if raw == 0 { |
| 83 | return; |
| 84 | } |
| 85 | if let Some(&id) = self.node_to_id.get(node) |
| 86 | && let Some(slot) = self.node_surrogates.get_mut(id as usize) |
| 87 | { |
| 88 | *slot = raw; |
| 89 | self.surrogate_to_local.insert(raw, id); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | /// Return the raw surrogate `u32` for a CSR-local node id. |
| 94 | /// |