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

Method adjacent_key

code/chapter08/graph_adjlist.rs:20–26  ·  view source on GitHub ↗

判断与当前点是否相邻

(&self, key: &T)

Source from the content-addressed store, hash-verified

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

Callers 2

remove_vertexMethod · 0.45
is_adjacentMethod · 0.45

Calls 1

iterMethod · 0.45

Tested by

no test coverage detected