Skip to content

Commit

Permalink
Fixed problem with degree distribution chart.
Browse files Browse the repository at this point in the history
 It was was not getting reset when the graph was updated. The issue only affected the visualisation- the underlying calculations are correct (as illustrated by the newly added unit test) Closes #44.
  • Loading branch information
mbatchkarov committed Jul 3, 2014
1 parent 84ad088 commit 2b404ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/controller/Stats.java
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ public void updateDegreeDistributionChartData(boolean cumulative) {
} else {
buckets = getCumulativeDegreeDistribution();
}
this.degreeDistXYSeries.clear();
for (int i = 0; i < buckets.length; i++) {
if (buckets[i] > 0) {
if (buckets[i] > 0) {
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/controller/StatsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,16 @@ public void testGetAvgDegree() throws Exception {
glass.addEdge(e(4), v(1), v(3));
assertEquals(2.5, glassStats.getAvgDegree(), 0.01);
}

@Test
public void testGetDegreDistribution(){

Stats s = new Stats(triangle);
assertArrayEquals(s.getDegreeDistribution(),
new int[]{0, 0, 3}); // three vertices of degree 2

s = new Stats(glass);
assertArrayEquals(s.getDegreeDistribution(),
new int[]{0, 1, 2, 1});
}
}

0 comments on commit 2b404ba

Please sign in to comment.