Make test more readable.
@@ -114,14 +114,11 @@ public class BayesianNetworkTest {
BoolVertex a = new BernoulliVertex(probTrue);
Set<Vertex> connectedGraph = a.getConnectedGraph();
BayesianNetwork net = new BayesianNetwork(connectedGraph);
- int initialVertexCount = connectedGraph.size();
-
- assertThat(initialVertexCount, equalTo(2));
BoolVertex b = new BernoulliVertex(0.5);
BoolVertex ored = a.or(b);
- assertThat(net.getVertexCount(), equalTo(initialVertexCount));
+ assertThat(net.getVertexCount(), equalTo(2));
}
@Test
@@ -129,15 +126,12 @@ public class BayesianNetworkTest {
ConstantDoubleVertex probTrue = ConstantVertex.of(0.5);
BoolVertex a = new BernoulliVertex(probTrue);
BayesianNetwork net = new BayesianNetwork(a.getConnectedGraph());
- int initialDegreeOfA = a.getDegree();
-
- assertThat(initialDegreeOfA, equalTo(1));
BoolVertex b = new BernoulliVertex(0.5);
BoolVertex ored = a.or(b);
- assertThat(net.getVertexDegree(a.getId()), equalTo(initialDegreeOfA));
- assertThat(net.getVertexDegree(a), equalTo(initialDegreeOfA));
+ assertThat(net.getVertexDegree(a.getId()), equalTo(1));
+ assertThat(net.getVertexDegree(a), equalTo(1));
}
@Test
@@ -154,16 +148,12 @@ public class BayesianNetworkTest {
GaussianVertex a = new GaussianVertex(mu, sigma);
GaussianVertex b = new GaussianVertex(a, sigma);
GaussianVertex c = new GaussianVertex(a, sigma);
- Set<Vertex> connectedGraph = a.getConnectedGraph();
- BayesianNetwork net = new BayesianNetwork(connectedGraph);
- double initialAverageVertexDegree = connectedGraph.stream().mapToInt(Vertex::getDegree).average().getAsDouble();
-
- assertThat(initialAverageVertexDegree, equalTo((1. + 3. + 4. + 2. + 2.) / 5.));
+ BayesianNetwork net = new BayesianNetwork(a.getConnectedGraph());
GaussianVertex d = new GaussianVertex(a, 1.);
GaussianVertex e = new GaussianVertex(a, 1.);
- assertThat(net.getAverageVertexDegree(), equalTo(initialAverageVertexDegree));
+ assertThat(net.getAverageVertexDegree(), equalTo((1. + 3. + 4. + 2. + 2.) / 5.));
}
@Test
@@ -177,8 +167,8 @@ public class BayesianNetworkTest {
Set<Vertex> connectedGraphInLoop = output.getConnectedGraph();
BayesianNetwork net = new BayesianNetwork(connectedGraphInLoop);
- assertThat(net.getVertexCount(), equalTo(connectedGraphInLoop.size()));
- assertThat(net.getVertexDegree(output), equalTo(output.getDegree()));
+ assertThat(net.getVertexCount(), equalTo(1 + 9 * Loop.DEFAULT_MAX_COUNT + 2));
+ assertThat(net.getVertexDegree(output), equalTo(3));
assertThat(net.getAverageVertexDegree(), equalTo(connectedGraphInLoop.stream().mapToInt(Vertex::getDegree).average().getAsDouble()));
}
}
