Skip to content

Commit e1372cc

Browse files
Committing, but will remove much of the work that has been done to take a different approach.
1 parent 11dceac commit e1372cc

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

dsm/src/main/java/org/hjug/dsm/DSM.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ void printDSM(Graph<String, DefaultWeightedEdge> graph, List<String> sortedActiv
278278
}
279279
}
280280

281+
// TODO: Delete all code below this line
282+
// Will be superseded by Minimum Feedback Arc + Vertex calculations
281283
/////////////////////////////////////////////////////////
282284
// "Standard" Graph implementation to find edge to remove
283285
/////////////////////////////////////////////////////////

dsm/src/main/java/org/hjug/dsm/SparseIntDWGEdgeRemovalCalculator.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.util.stream.Collectors;
1616
import java.util.stream.IntStream;
1717

18+
// TODO: Delete
1819
class SparseIntDWGEdgeRemovalCalculator {
1920
private final Graph<String, DefaultWeightedEdge> graph;
2021
SparseIntDirectedWeightedGraph sparseGraph;
@@ -35,7 +36,6 @@ class SparseIntDWGEdgeRemovalCalculator {
3536
int vertexCount,
3637
Map<String, Integer> vertexToInt,
3738
Map<Integer, String> intToVertex) {
38-
//TODO: Use concurrent types where possible
3939
this.graph = graph;
4040
this.sparseGraph = sparseGraph;
4141
this.sparseEdges = new CopyOnWriteArrayList<>(sparseEdges);
@@ -83,7 +83,8 @@ private EdgeToRemoveInfo calculateSparseEdgeToRemoveInfo(Integer edgeToRemove) {
8383

8484
private List<Integer> orderVertices(SparseIntDirectedWeightedGraph sparseGraph) {
8585
List<Set<Integer>> sccs = new CopyOnWriteArrayList<>(findStronglyConnectedSparseGraphComponents(sparseGraph));
86-
List<Integer> sparseIntSortedActivities = topologicalSortSparseGraph(sccs, sparseGraph);
86+
// List<Integer> sparseIntSortedActivities = topologicalSortSparseGraph(sccs, sparseGraph);
87+
List<Integer> sparseIntSortedActivities = topologicalParallelSortSparseGraph(sccs, sparseGraph);
8788
// reversing corrects rendering of the DSM
8889
// with sources as rows and targets as columns
8990
// was needed after AI solution was generated and iterated
@@ -155,7 +156,7 @@ private List<Integer> topologicalParallelSortSparseGraph(List<Set<Integer>> sccs
155156
ConcurrentLinkedQueue<Integer> sortedActivities = new ConcurrentLinkedQueue<>();
156157
Set<Integer> visited = new ConcurrentSkipListSet<>();
157158

158-
sccs.stream()
159+
sccs.parallelStream()
159160
.flatMap(Set::parallelStream)
160161
.filter(activity -> !visited.contains(activity))
161162
.forEach(activity -> topologicalSortUtilSparseGraph(activity, visited, sortedActivities, graph));
@@ -169,11 +170,9 @@ private void topologicalSortUtilSparseGraph(
169170
Integer activity, Set<Integer> visited, ConcurrentLinkedQueue<Integer> sortedActivities, Graph<Integer, Integer> graph) {
170171
visited.add(activity);
171172

172-
for (Integer neighbor : Graphs.successorListOf(graph, activity)) {
173-
if (!visited.contains(neighbor)) {
174-
topologicalSortUtilSparseGraph(neighbor, visited, sortedActivities, graph);
175-
}
176-
}
173+
Graphs.successorListOf(graph, activity).parallelStream()
174+
.filter(neighbor -> !visited.contains(neighbor))
175+
.forEach(neighbor -> topologicalSortUtilSparseGraph(neighbor, visited, sortedActivities, graph));
177176

178177
sortedActivities.add(activity);
179178
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@
390390
<plugin>
391391
<groupId>com.diffplug.spotless</groupId>
392392
<artifactId>spotless-maven-plugin</artifactId>
393-
<version>2.30.0</version>
393+
<version>2.44.5</version>
394394
<configuration>
395395
<formats>
396396
<!-- you can define as many formats as you want, each is independent -->

report/src/main/java/org/hjug/refactorfirst/report/SimpleHtmlReport.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,10 @@ public StringBuilder generateReport(
215215
edgesAboveDiagonal = dsm.getEdgesAboveDiagonal();
216216

217217
log.info("Performing edge removal what-if analysis");
218-
List<EdgeToRemoveInfo> edgeToRemoveInfos = dsm.getImpactOfSparseEdgesAboveDiagonalIfRemoved();
218+
// List<EdgeToRemoveInfo> edgeToRemoveInfos = dsm.getImpactOfSparseEdgesAboveDiagonalIfRemoved();
219219

220-
if (edgeToRemoveInfos.isEmpty()
221-
&& rankedGodClassDisharmonies.isEmpty()
220+
if (/*edgeToRemoveInfos.isEmpty()
221+
&&*/ rankedGodClassDisharmonies.isEmpty()
222222
&& rankedCBODisharmonies.isEmpty()
223223
&& rankedCycles.isEmpty()) {
224224
stringBuilder
@@ -232,10 +232,10 @@ public StringBuilder generateReport(
232232
return stringBuilder;
233233
}
234234

235-
if (!edgeToRemoveInfos.isEmpty()) {
236-
stringBuilder.append("<a href=\"#EDGES\">Back Edges</a>\n");
237-
stringBuilder.append("<br/>\n");
238-
}
235+
// if (!edgeToRemoveInfos.isEmpty()) {
236+
// stringBuilder.append("<a href=\"#EDGES\">Back Edges</a>\n");
237+
// stringBuilder.append("<br/>\n");
238+
// }
239239

240240
if (!rankedGodClassDisharmonies.isEmpty()) {
241241
stringBuilder.append("<a href=\"#GOD\">God Classes</a>\n");
@@ -259,13 +259,13 @@ public StringBuilder generateReport(
259259

260260
// Display impact of each edge if removed
261261
stringBuilder.append("<br/>\n");
262-
String edgeInfos = renderEdgeToRemoveInfos(edgeToRemoveInfos);
263-
264-
if (!edgeToRemoveInfos.isEmpty()) {
265-
stringBuilder.append(edgeInfos);
266-
stringBuilder.append(renderGithubButtons());
267-
stringBuilder.append("<br/>\n" + "<br/>\n" + "<br/>\n" + "<br/>\n" + "<hr/>\n" + "<br/>\n" + "<br/>\n");
268-
}
262+
// String edgeInfos = renderEdgeToRemoveInfos(edgeToRemoveInfos);
263+
//
264+
// if (!edgeToRemoveInfos.isEmpty()) {
265+
// stringBuilder.append(edgeInfos);
266+
// stringBuilder.append(renderGithubButtons());
267+
// stringBuilder.append("<br/>\n" + "<br/>\n" + "<br/>\n" + "<br/>\n" + "<hr/>\n" + "<br/>\n" + "<br/>\n");
268+
// }
269269

270270
if (!rankedGodClassDisharmonies.isEmpty()) {
271271
final String[] godClassTableHeadings =

0 commit comments

Comments
 (0)