Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
Use undirected edges instead of iterating
Browse files Browse the repository at this point in the history
  • Loading branch information
floriandejonckheere committed Mar 31, 2024
1 parent 62b54d2 commit 427c49d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/mosaik/extractors/evolution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,15 @@ def call

info "Constructing contributor coupling graph..."

# FIXME: add undirected edges instead of iterating over all permutation
contributors.keys.permutation(2).each do |(a, b)|
next if contributors[a].empty? || contributors[b].empty?
contributors.keys.each do |(a, b)|
next if a == b || contributors[a].empty? || contributors[b].empty?

graph.find_or_add_vertex(a)
graph.find_or_add_vertex(b)

# Add a weighted edge to the graph (weight is the cardinality of the intersection of sets)
# FIXME: aggregate with existing edges
graph.add_directed_edge(a, b, weight: (contributors[a] & contributors[b]).count * options[:contributor])
graph.add_undirected_edge(a, b, weight: (contributors[a] & contributors[b]).count * options[:contributor])
end
end

Expand Down

0 comments on commit 427c49d

Please sign in to comment.