| 51 | } |
| 52 | |
| 53 | TEST(SpanningTree, Nominal) { |
| 54 | // Triangle: edges with weights 1, 2, 3. |
| 55 | // Max spanning tree uses edges 2+3=5, min uses 1+2=3. |
| 56 | const std::vector<std::pair<int, int>> edges = {{0, 1}, {1, 2}, {0, 2}}; |
| 57 | const std::vector<float> weights = {1.0f, 2.0f, 3.0f}; |
| 58 | |
| 59 | const SpanningTree max_tree = ComputeMaximumSpanningTree(3, edges, weights); |
| 60 | const SpanningTree min_tree = ComputeMinimumSpanningTree(3, edges, weights); |
| 61 | |
| 62 | EXPECT_EQ(ComputeTreeWeight(max_tree, edges, weights), 5.0f); |
| 63 | EXPECT_EQ(ComputeTreeWeight(min_tree, edges, weights), 3.0f); |
| 64 | } |
| 65 | |
| 66 | TEST(SpanningTree, DisconnectedGraph) { |
| 67 | // Two components: {0,1} and {2,3}. Only component containing root is |
nothing calls this directly
no test coverage detected