MCPcopy Create free account
hub / github.com/colmap/colmap / ComputeTreeWeight

Function ComputeTreeWeight

src/colmap/math/spanning_tree_test.cc:38–51  ·  view source on GitHub ↗

Helper to compute total weight of edges in the spanning tree.

Source from the content-addressed store, hash-verified

36
37// Helper to compute total weight of edges in the spanning tree.
38float ComputeTreeWeight(const SpanningTree& tree,
39 const std::vector<std::pair<int, int>>& edges,
40 const std::vector<float>& weights) {
41 float total = 0;
42 for (size_t i = 0; i < edges.size(); ++i) {
43 int u = edges[i].first;
44 int v = edges[i].second;
45 // Check if this edge is in the tree (either direction).
46 if (tree.parents[u] == v || tree.parents[v] == u) {
47 total += weights[i];
48 }
49 }
50 return total;
51}
52
53TEST(SpanningTree, Nominal) {
54 // Triangle: edges with weights 1, 2, 3.

Callers 1

TESTFunction · 0.85

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected