Initial release #1
+13
-16
@@ -165,41 +165,38 @@ fn main() {
|
||||
graph.add_edge(vertices[7], vertices[8]);
|
||||
graph.add_edge(vertices[7], vertices[9]);
|
||||
|
||||
assert_eq!(graph.vertex_count(), 10, "vertex count");
|
||||
assert_eq!(graph.edge_count(), 14, "edge count");
|
||||
assert_eq!(graph.vertex_count(), 10, "unexpected vertex count");
|
||||
assert_eq!(graph.edge_count(), 14, "unexpected edge count");
|
||||
let expected_degrees = [1, 4, 4, 2, 4, 2, 3, 3, 2, 3];
|
||||
for i in 0..graph.vertex_count() {
|
||||
assert_eq!(
|
||||
graph.degree(vertices[i]),
|
||||
expected_degrees[i],
|
||||
"degree of {:?}",
|
||||
"unexpected degree of {:?}",
|
||||
vertices[i]
|
||||
);
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
assert!(
|
||||
graph.are_adjacent(vertices[0], vertices[1]),
|
||||
true,
|
||||
"adjacency of {:?} and {:?}",
|
||||
"expected {:?} and {:?} to be adjacent",
|
||||
vertices[0],
|
||||
vertices[1]
|
||||
);
|
||||
assert_eq!(
|
||||
assert!(
|
||||
graph.are_adjacent(vertices[9], vertices[5]),
|
||||
true,
|
||||
"adjacency of {:?} and {:?}",
|
||||
"expected {:?} and {:?} to be adjacent",
|
||||
vertices[0],
|
||||
vertices[5]
|
||||
);
|
||||
assert_eq!(
|
||||
graph.are_adjacent(vertices[9], vertices[3]),
|
||||
false,
|
||||
"adjacency of {:?} and {:?}",
|
||||
assert!(
|
||||
!graph.are_adjacent(vertices[9], vertices[3]),
|
||||
"unexpected adjacency of {:?} and {:?}",
|
||||
vertices[9],
|
||||
vertices[3]
|
||||
);
|
||||
|
||||
for i in 0..vertices.len() {
|
||||
for i in 0..graph.vertex_count() {
|
||||
let exp = match i {
|
||||
2 => continue,
|
||||
1 | 4 | 5 | 6 => true,
|
||||
@@ -208,14 +205,14 @@ fn main() {
|
||||
assert_eq!(
|
||||
graph.are_adjacent(vertices[2], vertices[i]),
|
||||
exp,
|
||||
"adjacency of {:?} and {:?}",
|
||||
"unexpected adjacency of {:?} and {:?}",
|
||||
vertices[2],
|
||||
vertices[i]
|
||||
);
|
||||
assert_eq!(
|
||||
graph.are_adjacent(vertices[i], vertices[2]),
|
||||
exp,
|
||||
"adjacency of {:?} and {:?}",
|
||||
"unexpected adjacency of {:?} and {:?}",
|
||||
vertices[i],
|
||||
vertices[2]
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user