Skip to content

Commit 1d07fde

Browse files
assaronSpace Cloud
authored and
Space Cloud
committed
Constraint generation fixes (including connectivity fix)
1 parent 230b977 commit 1d07fde

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: mwcsr
22
Title: Solvers for Maximum Weight Connected Subgraph Problem and Its Variants
3-
Version: 0.1.7
3+
Version: 0.1.8
44
Authors@R: c(person("Alexander", "Loboda", email = "[email protected]", role = c("aut", "cre")),
55
person("Nikolay", "Poperechnyi", email = "[email protected]", role = "aut"),
66
person("Eduardo", "Alvarez-Miranda", email = "[email protected]", role = "aut"),

src/sgmwcs/components.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,17 @@ std::vector<Component> Component::get_components(mwcsr::Graph& g, std::vector<si
5454
}
5555
for (auto v: {g.edge(e).from(), g.edge(e).to()}) {
5656
for (auto e: g.neighbours(v)) {
57-
if (!(visited.find(e.num()) == visited.end())) continue;
58-
visited.insert(e.num());
59-
if (solution.count(e.num())) {
60-
q.push(e.num());
61-
} else {
57+
if (!solution.count(e.num())) {
6258
c.add_neighbour(e.num());
59+
continue;
60+
}
61+
62+
if (!(visited.find(e.num()) == visited.end())) {
63+
continue;
6364
}
65+
visited.insert(e.num());
66+
67+
q.push(e.num());
6468
}
6569
}
6670
}
@@ -89,4 +93,4 @@ double Component::get_revenue() const {
8993
return max_revenue;
9094
}
9195

92-
}
96+
}

0 commit comments

Comments
 (0)