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

Method add_edge

publication/code/chapter09/graph_matrix.rs:56–62  ·  view source on GitHub ↗

添加边,设置边属性为 true

(&mut self, n1: &Vertex, n2: &Vertex)

Source from the content-addressed store, hash-verified

54
55 // 添加边,设置边属性为 true
56 fn add_edge(&mut self, n1: &Vertex, n2: &Vertex) {
57 if n1.id < self.nodes && n2.id < self.nodes {
58 self.graph[n1.id][n2.id] = Edge::set_edge();
59 } else {
60 println!("Error, vertex beyond the graph");
61 }
62 }
63}
64
65fn main() {

Callers 1

mainFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected