1 | package net.bmahe.genetics4j.neat.util; | |
2 | ||
3 | import java.util.List; | |
4 | import java.util.Map; | |
5 | import java.util.Map.Entry; | |
6 | import java.util.Set; | |
7 | ||
8 | import org.apache.commons.lang3.Validate; | |
9 | ||
10 | import net.bmahe.genetics4j.neat.Connection; | |
11 | import net.bmahe.genetics4j.neat.chromosomes.NeatChromosome; | |
12 | ||
13 | public class GraphvizFormatter { | |
14 | ||
15 | public String format(final NeatChromosome neatChromosome, final Map<Integer, String> nodeNames) { | |
16 | Validate.notNull(neatChromosome); | |
17 | Validate.notNull(nodeNames); | |
18 | ||
19 |
1
1. format : removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getConnections → NO_COVERAGE |
final List<Connection> connections = neatChromosome.getConnections(); |
20 |
1
1. format : removed call to java/lang/StringBuilder::<init> → NO_COVERAGE |
final StringBuilder graphStringBuilder = new StringBuilder(); |
21 | ||
22 |
2
1. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 2. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE |
graphStringBuilder.append(""" |
23 | digraph g { | |
24 | rankdir=LR; | |
25 | root[style="invis"] | |
26 | end[style="invis"] | |
27 | """); | |
28 | ||
29 |
1
1. format : removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getInputNodeIndices → NO_COVERAGE |
final Set<Integer> inputNodeIndices = neatChromosome.getInputNodeIndices(); |
30 | for (final Integer inputNodeIndex : inputNodeIndices) { | |
31 |
2
1. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE 2. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE |
graphStringBuilder.append("\troot -> ") |
32 |
2
1. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 2. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE |
.append(inputNodeIndex) |
33 |
2
1. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 2. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE |
.append(" [style=\"invis\"]") |
34 |
3
1. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 2. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE 3. format : removed call to java/lang/System::lineSeparator → NO_COVERAGE |
.append(System.lineSeparator()); |
35 | } | |
36 | ||
37 |
1
1. format : removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getOutputNodeIndices → NO_COVERAGE |
final Set<Integer> outputNodeIndices = neatChromosome.getOutputNodeIndices(); |
38 | for (final Integer outputNodeIndex : outputNodeIndices) { | |
39 |
2
1. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 2. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE |
graphStringBuilder.append("\t") |
40 |
2
1. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 2. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE |
.append(outputNodeIndex) |
41 |
2
1. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 2. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE |
.append(" -> end") |
42 |
2
1. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 2. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE |
.append(" [style=\"invis\"]") |
43 |
3
1. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE 2. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 3. format : removed call to java/lang/System::lineSeparator → NO_COVERAGE |
.append(System.lineSeparator()); |
44 | } | |
45 | ||
46 | for (final Connection connection : connections) { | |
47 | ||
48 |
1
1. format : removed call to net/bmahe/genetics4j/neat/Connection::fromNodeIndex → NO_COVERAGE |
final int fromNodeIndex = connection.fromNodeIndex(); |
49 |
1
1. format : removed call to net/bmahe/genetics4j/neat/Connection::toNodeIndex → NO_COVERAGE |
final int toNodeIndex = connection.toNodeIndex(); |
50 |
1
1. format : removed call to net/bmahe/genetics4j/neat/Connection::innovation → NO_COVERAGE |
final int innovation = connection.innovation(); |
51 |
1
1. format : removed call to net/bmahe/genetics4j/neat/Connection::isEnabled → NO_COVERAGE |
final boolean enabled = connection.isEnabled(); |
52 |
1
1. format : removed call to net/bmahe/genetics4j/neat/Connection::weight → NO_COVERAGE |
final float weight = connection.weight(); |
53 | ||
54 |
1
1. format : removed call to java/lang/StringBuilder::<init> → NO_COVERAGE |
final StringBuilder connectionStrBuilder = new StringBuilder(); |
55 |
2
1. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 2. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE |
connectionStrBuilder.append(fromNodeIndex); |
56 |
2
1. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE 2. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE |
connectionStrBuilder.append(" -> "); |
57 |
2
1. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE 2. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE |
connectionStrBuilder.append(toNodeIndex); |
58 |
2
1. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE 2. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE |
connectionStrBuilder.append(" [ "); |
59 |
3
1. format : removed conditional - replaced equality check with true → NO_COVERAGE 2. format : negated conditional → NO_COVERAGE 3. format : removed conditional - replaced equality check with false → NO_COVERAGE |
if (enabled == false) { |
60 |
2
1. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 2. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE |
connectionStrBuilder.append("style=\"dashed\", "); |
61 | } | |
62 |
9
1. format : removed call to java/lang/Float::valueOf → NO_COVERAGE 2. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE 3. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 4. format : Substituted 2 with 3 → NO_COVERAGE 5. format : removed call to java/lang/Integer::valueOf → NO_COVERAGE 6. format : replaced call to java/lang/String::format with argument → NO_COVERAGE 7. format : Substituted 1 with 0 → NO_COVERAGE 8. format : removed call to java/lang/String::format → NO_COVERAGE 9. format : Substituted 0 with 1 → NO_COVERAGE |
connectionStrBuilder.append(String.format("label=\"innovation=%d, weight=%.03f\"", innovation, weight)); |
63 |
2
1. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 2. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE |
connectionStrBuilder.append(" ] "); |
64 |
3
1. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 2. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE 3. format : removed call to java/lang/System::lineSeparator → NO_COVERAGE |
connectionStrBuilder.append(System.lineSeparator()); |
65 | ||
66 |
2
1. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 2. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE |
graphStringBuilder.append("\t"); |
67 |
3
1. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE 2. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 3. format : removed call to java/lang/StringBuilder::toString → NO_COVERAGE |
graphStringBuilder.append(connectionStrBuilder.toString()); |
68 | } | |
69 | ||
70 |
1
1. format : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (final Entry<Integer, String> nodeNamesEntry : nodeNames.entrySet()) { |
71 | ||
72 |
2
1. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 2. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE |
graphStringBuilder.append("\t") |
73 |
5
1. format : removed call to java/lang/Integer::intValue → NO_COVERAGE 2. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE 3. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 4. format : removed call to java/util/Map$Entry::getKey → NO_COVERAGE 5. format : removed call to java/lang/Integer::toString → NO_COVERAGE |
.append(Integer.toString(nodeNamesEntry.getKey())) |
74 |
2
1. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE 2. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE |
.append("[ ") |
75 |
2
1. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE 2. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE |
.append("label=\"") |
76 |
3
1. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 2. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE 3. format : removed call to java/util/Map$Entry::getValue → NO_COVERAGE |
.append(nodeNamesEntry.getValue()) |
77 |
2
1. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 2. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE |
.append("\"") |
78 |
2
1. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 2. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE |
.append(" ]") |
79 |
3
1. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE 2. format : removed call to java/lang/System::lineSeparator → NO_COVERAGE 3. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE |
.append(System.lineSeparator()); |
80 | } | |
81 | ||
82 |
2
1. format : replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE 2. format : removed call to java/lang/StringBuilder::append → NO_COVERAGE |
graphStringBuilder.append("}"); |
83 |
2
1. format : removed call to java/lang/StringBuilder::toString → NO_COVERAGE 2. format : replaced return value with "" for net/bmahe/genetics4j/neat/util/GraphvizFormatter::format → NO_COVERAGE |
return graphStringBuilder.toString(); |
84 | } | |
85 | } | |
Mutations | ||
19 |
1.1 |
|
20 |
1.1 |
|
22 |
1.1 2.2 |
|
29 |
1.1 |
|
31 |
1.1 2.2 |
|
32 |
1.1 2.2 |
|
33 |
1.1 2.2 |
|
34 |
1.1 2.2 3.3 |
|
37 |
1.1 |
|
39 |
1.1 2.2 |
|
40 |
1.1 2.2 |
|
41 |
1.1 2.2 |
|
42 |
1.1 2.2 |
|
43 |
1.1 2.2 3.3 |
|
48 |
1.1 |
|
49 |
1.1 |
|
50 |
1.1 |
|
51 |
1.1 |
|
52 |
1.1 |
|
54 |
1.1 |
|
55 |
1.1 2.2 |
|
56 |
1.1 2.2 |
|
57 |
1.1 2.2 |
|
58 |
1.1 2.2 |
|
59 |
1.1 2.2 3.3 |
|
60 |
1.1 2.2 |
|
62 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 |
|
63 |
1.1 2.2 |
|
64 |
1.1 2.2 3.3 |
|
66 |
1.1 2.2 |
|
67 |
1.1 2.2 3.3 |
|
70 |
1.1 |
|
72 |
1.1 2.2 |
|
73 |
1.1 2.2 3.3 4.4 5.5 |
|
74 |
1.1 2.2 |
|
75 |
1.1 2.2 |
|
76 |
1.1 2.2 3.3 |
|
77 |
1.1 2.2 |
|
78 |
1.1 2.2 |
|
79 |
1.1 2.2 3.3 |
|
82 |
1.1 2.2 |
|
83 |
1.1 2.2 |