Sha256: d1c96d897ce6234fd229dc8322a13b2239643ce2d3bb2e6c184113a5aa102db2

Contents?: true

Size: 498 Bytes

Versions: 2

Compression:

Stored size: 498 Bytes

Contents

module FindCommunities
  class Graph
    def initialize(file, type=nil)
      weight = 1.0
      links = []

      nb_links = file.count
      file.each do |line|
        pieces = line.split
        src = pieces[0].to_i
        dest = pieces[1].to_i
        weight = pieces[2].to_f if type == :weighted
        links[src] ||= []
        links[src] << [dest, weight]
        if src != dest
          links[dest] ||= []
          links[dest] ||= [src, weight]
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
find_communities-0.0.3 lib/find_communities/graph.rb
find_communities-0.0.1 lib/find_communities/graph.rb