GraphvizFormatter.java

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.Objects;
7
import java.util.Set;
8
9
import net.bmahe.genetics4j.neat.Connection;
10
import net.bmahe.genetics4j.neat.chromosomes.NeatChromosome;
11
12
public class GraphvizFormatter {
13
14
	public String format(final NeatChromosome neatChromosome, final Map<Integer, String> nodeNames) {
15
		Objects.requireNonNull(neatChromosome);
16
		Objects.requireNonNull(nodeNames);
17
18 1 1. format : removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getConnections → NO_COVERAGE
		final List<Connection> connections = neatChromosome.getConnections();
19 1 1. format : removed call to java/lang/StringBuilder::<init> → NO_COVERAGE
		final StringBuilder graphStringBuilder = new StringBuilder();
20
21 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("""
22
				digraph g {
23
					rankdir=LR;
24
					root[style="invis"]
25
					end[style="invis"]
26
				""");
27
28 1 1. format : removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getInputNodeIndices → NO_COVERAGE
		final Set<Integer> inputNodeIndices = neatChromosome.getInputNodeIndices();
29
		for (final Integer inputNodeIndex : inputNodeIndices) {
30 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 -> ")
31 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)
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(" [style=\"invis\"]")
33 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());
34
		}
35
36 1 1. format : removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getOutputNodeIndices → NO_COVERAGE
		final Set<Integer> outputNodeIndices = neatChromosome.getOutputNodeIndices();
37
		for (final Integer outputNodeIndex : outputNodeIndices) {
38 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")
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
					.append(outputNodeIndex)
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(" -> end")
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(" [style=\"invis\"]")
42 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());
43
		}
44
45
		for (final Connection connection : connections) {
46
47 1 1. format : removed call to net/bmahe/genetics4j/neat/Connection::fromNodeIndex → NO_COVERAGE
			final int fromNodeIndex = connection.fromNodeIndex();
48 1 1. format : removed call to net/bmahe/genetics4j/neat/Connection::toNodeIndex → NO_COVERAGE
			final int toNodeIndex = connection.toNodeIndex();
49 1 1. format : removed call to net/bmahe/genetics4j/neat/Connection::innovation → NO_COVERAGE
			final int innovation = connection.innovation();
50 1 1. format : removed call to net/bmahe/genetics4j/neat/Connection::isEnabled → NO_COVERAGE
			final boolean enabled = connection.isEnabled();
51 1 1. format : removed call to net/bmahe/genetics4j/neat/Connection::weight → NO_COVERAGE
			final float weight = connection.weight();
52
53 1 1. format : removed call to java/lang/StringBuilder::<init> → NO_COVERAGE
			final StringBuilder connectionStrBuilder = new StringBuilder();
54 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);
55 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(" -> ");
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(toNodeIndex);
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(" [ ");
58 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) {
59 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\", ");
60
			}
61 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));
62 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(" ] ");
63 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());
64
65 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");
66 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());
67
		}
68
69 1 1. format : removed call to java/util/Map::entrySet → NO_COVERAGE
		for (final Entry<Integer, String> nodeNamesEntry : nodeNames.entrySet()) {
70
71 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")
72 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()))
73 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("[ ")
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("label=\"")
75 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())
76 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("\"")
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 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());
79
		}
80
81 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("}");
82 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();
83
	}
84
}

Mutations

18

1.1
Location : format
Killed by : none
removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getConnections → NO_COVERAGE

19

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::<init> → NO_COVERAGE

21

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

28

1.1
Location : format
Killed by : none
removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getInputNodeIndices → NO_COVERAGE

30

1.1
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

2.2
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

31

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

32

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

33

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

3.3
Location : format
Killed by : none
removed call to java/lang/System::lineSeparator → NO_COVERAGE

36

1.1
Location : format
Killed by : none
removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getOutputNodeIndices → NO_COVERAGE

38

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

39

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

40

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

41

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

42

1.1
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

2.2
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

3.3
Location : format
Killed by : none
removed call to java/lang/System::lineSeparator → NO_COVERAGE

47

1.1
Location : format
Killed by : none
removed call to net/bmahe/genetics4j/neat/Connection::fromNodeIndex → NO_COVERAGE

48

1.1
Location : format
Killed by : none
removed call to net/bmahe/genetics4j/neat/Connection::toNodeIndex → NO_COVERAGE

49

1.1
Location : format
Killed by : none
removed call to net/bmahe/genetics4j/neat/Connection::innovation → NO_COVERAGE

50

1.1
Location : format
Killed by : none
removed call to net/bmahe/genetics4j/neat/Connection::isEnabled → NO_COVERAGE

51

1.1
Location : format
Killed by : none
removed call to net/bmahe/genetics4j/neat/Connection::weight → NO_COVERAGE

53

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::<init> → NO_COVERAGE

54

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

55

1.1
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

2.2
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

56

1.1
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

2.2
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

57

1.1
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

2.2
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

58

1.1
Location : format
Killed by : none
removed conditional - replaced equality check with true → NO_COVERAGE

2.2
Location : format
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : format
Killed by : none
removed conditional - replaced equality check with false → NO_COVERAGE

59

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

61

1.1
Location : format
Killed by : none
removed call to java/lang/Float::valueOf → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

3.3
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

4.4
Location : format
Killed by : none
Substituted 2 with 3 → NO_COVERAGE

5.5
Location : format
Killed by : none
removed call to java/lang/Integer::valueOf → NO_COVERAGE

6.6
Location : format
Killed by : none
replaced call to java/lang/String::format with argument → NO_COVERAGE

7.7
Location : format
Killed by : none
Substituted 1 with 0 → NO_COVERAGE

8.8
Location : format
Killed by : none
removed call to java/lang/String::format → NO_COVERAGE

9.9
Location : format
Killed by : none
Substituted 0 with 1 → NO_COVERAGE

62

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

63

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

3.3
Location : format
Killed by : none
removed call to java/lang/System::lineSeparator → NO_COVERAGE

65

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

66

1.1
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

2.2
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

3.3
Location : format
Killed by : none
removed call to java/lang/StringBuilder::toString → NO_COVERAGE

69

1.1
Location : format
Killed by : none
removed call to java/util/Map::entrySet → NO_COVERAGE

71

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

72

1.1
Location : format
Killed by : none
removed call to java/lang/Integer::intValue → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

3.3
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

4.4
Location : format
Killed by : none
removed call to java/util/Map$Entry::getKey → NO_COVERAGE

5.5
Location : format
Killed by : none
removed call to java/lang/Integer::toString → NO_COVERAGE

73

1.1
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

2.2
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

74

1.1
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

2.2
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

75

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

3.3
Location : format
Killed by : none
removed call to java/util/Map$Entry::getValue → NO_COVERAGE

76

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

77

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

78

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

2.2
Location : format
Killed by : none
removed call to java/lang/System::lineSeparator → NO_COVERAGE

3.3
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

81

1.1
Location : format
Killed by : none
replaced call to java/lang/StringBuilder::append with receiver → NO_COVERAGE

2.2
Location : format
Killed by : none
removed call to java/lang/StringBuilder::append → NO_COVERAGE

82

1.1
Location : format
Killed by : none
removed call to java/lang/StringBuilder::toString → NO_COVERAGE

2.2
Location : format
Killed by : none
replaced return value with "" for net/bmahe/genetics4j/neat/util/GraphvizFormatter::format → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.20.3