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

Commit

Permalink
Calculate average of ABC sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
floriandejonckheere committed Apr 19, 2024
1 parent bf00ada commit 65d96a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/mosaik/metrics/abc_size.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def evaluate
.parse(file)

# Calculate the ABC size for the vertex
abc_size_v = abc_sizes.values.sum
abc_size_v = (abc_sizes.values.sum / abc_sizes.size).round(2)

# Store ABC size value in the vertex
v.attributes[:abc_size] = abc_size_v
Expand Down
14 changes: 7 additions & 7 deletions spec/mosaik/metrics/abc_size_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@

# ABC size value calculated by hand:
#
# Cluster 1: 1.0
# Cluster 2: 15.04 + 5.0
# Cluster 1: 1.0 / 1 = 1.0
# Cluster 2: 15.04 / 2 + 5.0 / 3 = 9.19 (rounded)
#
# ABC size = 21.04
# ABC size = 10.19
#

it "sets the ABC size values for each vertex, cluster, and for the graph" do
metric.evaluate

expect(graph.find_vertex("CoreExt::Object").attributes[:abc_size]).to eq 1.0
expect(graph.find_vertex("MOSAIK::Logger").attributes[:abc_size]).to eq 15.04
expect(graph.find_vertex("MOSAIK::Algorithm").attributes[:abc_size]).to eq 5.0
expect(graph.find_vertex("MOSAIK::Logger").attributes[:abc_size]).to eq 7.52
expect(graph.find_vertex("MOSAIK::Algorithm").attributes[:abc_size]).to eq 1.67

expect(graph.find_cluster("cluster1").attributes[:abc_size]).to eq 1.0
expect(graph.find_cluster("cluster2").attributes[:abc_size]).to eq 20.04
expect(graph.find_cluster("cluster2").attributes[:abc_size]).to eq 9.19

expect(graph.attributes[:abc_size]).to eq 21.04
expect(graph.attributes[:abc_size]).to eq 10.19
end
end

0 comments on commit 65d96a5

Please sign in to comment.