Sha256: 18af7b0c1ce9e89c46bcdbccdf684f787e9cc1183c36fcc5c70df49b546968bb

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'
require_relative 'fixtures/clustering/clusterer_fixtures.rb'

describe Society::Clusterer do

  describe "#cluster" do
    let(:clusterer) { Society::Clusterer.new }

    it "detects clusters" do
      clusters = clusterer.cluster(MCL::GRAPH_1).map(&:sort)
      expected = MCL::CLUSTERS_1.map(&:sort)
      expect(clusters).to match_array(expected)
    end

    context "with inflation parameter set to 1.7" do
      let(:clusterer) { Society::Clusterer.new(inflation: 1.7) }

      it "detects clusters at coarser granularity" do
        clusters = clusterer.cluster(MCL::GRAPH_1).map(&:sort)
        expected = MCL::CLUSTERS_1_I17.map(&:sort)
        expect(clusters).to match_array(expected)
      end
    end

    context "with inflation parameter set to 4.0" do
      let(:clusterer) { Society::Clusterer.new(inflation: 4.0) }

      it "detects clusters at finer granularity" do
        clusters = clusterer.cluster(MCL::GRAPH_1).map(&:sort)
        expected = MCL::CLUSTERS_1_I40.map(&:sort)
        expect(clusters).to match_array(expected)
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
society-1.1.1 spec/clusterer_spec.rb
society-1.1.0 spec/clusterer_spec.rb