@Test public void reflexiveReduce_removes_links_to_self() { for (int i = 0; i < matrix.size(); i++) { matrix.setEdge(i, i); } matrix.removeReflexiveEdges(); assertThat(matrix, is(emptyMatrix)); }
@Test public void howto_use_transitive_reduction_test() { createSimpleGraph(); matrix.setEdge(0, 0); // connect a vertex with itself assertThat( matrix.toString(), is("[1,1,1,0,0],[0,0,0,0,0],[0,0,0,1,0],[0,0,0,0,1],[0,1,0,0,0]")); matrix.removeReflexiveEdges(); assertThat( matrix.toString(), is("[0,1,1,0,0],[0,0,0,0,0],[0,0,0,1,0],[0,0,0,0,1],[0,1,0,0,0]")); matrix.produceTransitiveClosure(); assertThat( matrix.toString(), is("[0,1,1,1,1],[0,0,0,0,0],[0,1,0,1,1],[0,1,0,0,1],[0,1,0,0,0]")); matrix.transitiveReduction(); assertThat( matrix.toString(), is("[0,0,1,0,0],[0,0,0,0,0],[0,0,0,1,0],[0,0,0,0,1],[0,1,0,0,0]")); matrix.clear(); assertThat( matrix.toString(), is("[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]")); }