DD2480-2022-group-7 / Java

All Algorithms implemented in Java
MIT License
0 stars 0 forks source link

Method BellmanFord::go #7

Open samuelsoder opened 2 years ago

samuelsoder commented 2 years ago

The implementation of the Bellman-Ford algorithm with method go in src/main/java/com/thealgorithms/datastructures/graphs/BellmanFord.java has reported cyclomatic complexity 13 by lizard.

Part 1 steps:

Part 2 steps:

samuelsoder commented 2 years ago

The go method of the BellmanFord class

If = 3 || = 0 && = 2 While = 0 For = 7 Return = 1 (Void method, not printed at end)

M = 12 - 1 + 2 = 13

samuelsoder commented 2 years ago

This function with high CC is 57 LOC which is fairly long. The Bellman Ford algorithm is an algorithm for finding the shortest path from a source vertex to each other vertex in the graph. The purpose of the method is to calculate that path and distance to each other vertex. The for-loops used in the algorithm is needed, and the high CC is therefore connected to the complexity of the algorithm.

Exceptions are not taken into account by this tool.

The documentation is ok. Some further explanation of different parts of the algorithm would help in understanding what is being calculated at each step.

samuelsoder commented 2 years ago

Coverage prior to the implementation of new tests

BeforeCoverage-Jacoco BeforeCoverage-Manual
samuelsoder commented 2 years ago

Coverage efter the implementation of new test

IncreasedCoverage-Jacoco IncreasedCoverage-Manual