MCPcopy Create free account
hub / github.com/QMHTMY/RustBook / adjacent_key

Method adjacent_key

publication/code/chapter09/graph_adjlist.rs:22–28  ·  view source on GitHub ↗

判断与当前点是否相邻

(&self, key: &T)

Source from the content-addressed store, hash-verified

20
21 // 判断与当前点是否相邻
22 fn adjacent_key(&self, key: &T) -> bool {
23 for (nbr, _wt) in self.neighbors.iter() {
24 if nbr == key { return true; }
25 }
26
27 false
28 }
29
30 fn add_neighbor(&mut self, nbr: T, wt: i32) {
31 self.neighbors.push((nbr, wt));

Callers 2

remove_vertexMethod · 0.45
is_adjacentMethod · 0.45

Calls 1

iterMethod · 0.45

Tested by

no test coverage detected