Skip to content
This repository has been archived by the owner on Apr 26, 2019. It is now read-only.

Commit

Permalink
community: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kortschak committed Aug 18, 2016
1 parent e0421ad commit d5176e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions community/louvain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,15 @@ func reverse(f []float64) {
}
}

func hasNegative(f []float64) bool {
for _, v := range f {
if v < 0 {
return true
}
}
return false
}

var (
dupGraph = simple.NewUndirectedGraph(0, 0)
dupGraphDirected = simple.NewDirectedGraph(0, 0)
Expand Down
6 changes: 5 additions & 1 deletion community/louvain_undirected_multiplex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,14 @@ tests:
if i == communityOf[target.ID()] {
continue
}
if !all {
if !(all && hasNegative(weights)) {
connected := false
search:
for l := 0; l < g.Depth(); l++ {
if weights[l] < 0 {
connected = true
break search
}
layer := g.Layer(l)
for n := range c {
if layer.HasEdgeBetween(simple.Node(n), target) {
Expand Down

0 comments on commit d5176e2

Please sign in to comment.