Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: mwcsr
Title: Solvers for Maximum Weight Connected Subgraph Problem and Its Variants
Version: 0.1.11
Version: 0.1.12
Authors@R: c(person("Alexander", "Loboda", email = "aleks.loboda@gmail.com", role = c("aut", "cre")),
person("Nikolay", "Poperechnyi", email = "n.poperechnyi@gmail.com", role = "aut"),
person("Eduardo", "Alvarez-Miranda", email = "ealvarez@utalca.cl", role = "aut"),
Expand Down
1 change: 1 addition & 0 deletions R/rnc_sgmwcs.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ solve_mwcsp.rnc_solver <- function(solver, instance, ...) {

if (length(res$edges) == 0) {
g <- igraph::induced_subgraph(instance, vids = res$vertices)
g <- igraph::delete_edges(g, igraph::E(g))
} else {
g <- igraph::subgraph_from_edges(instance, eids = res$edges)
}
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test_rnc.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ test_that("rnc solver handles non-integer signal weights in single-vertex soluti
expect_equal(solution$weight, 2.193558)
})

test_that("rnc solver handles self-loops with negative signal weights (#13)", {
solver <- rnc_solver(max_iterations=50)
g <- igraph::make_graph(c(1, 1), directed=FALSE) # loop
V(g)$signal <- "s1"
E(g)$signal <- "s2"
g$signals <- c(s1=0, s2=-1)
solution <- solve_mwcsp(solver, g)
expect_equal(solution$weight, 0)
})

test_that("sgmwcs rnc solver gives good solution for a GAM instance", {
rnc <- rnc_solver(max_iterations = 100)
solution <- solve_mwcsp(rnc, gmwcs_example)
Expand Down
Loading