// SSDLPediapackageil.ac.technion.cs.cs236700.graph;
importstaticjava.lang.Math.max;
importil.ac.technion.cs.cs236700.graph.Graph.Vertex;
/** * Computes the longest walk from every node. Assumes that the graph has no * cycles, otherwise, the traversal will terminate but the result may not make * sense to some. * * <Data> the type of information stored in a graph node * Author: Yossi Gil * See: 26/06/2007 */publicclassLongestWalkProcessor<DataextendsComparable<Data>> extendsEmptyProcessor<Data, int[]> {
/** * Result of the longest walk computation. Position i in this * array will store the length of the longest walk possible starting from * the vertex numbered i. */privateint[] result;
@Overridepublicvoidbefore(finalGraph<Data> g) {
result = newint[g.vertices.length];
}
@Overridepublicvoidafter(finalVertex<Data> v) {
for (finalVertex<Data> u : v.to)
if (u != v)
result[v.i] = max(result[v.i], 1 + result[u.i]);
}
@Overridepublicint[] after(@SuppressWarnings("unused") finalGraph<Data> _) {
returnresult;
}
}
Metrics
Metric
Value
Acronym
Explanation
LOC
38
Lines Of Code
Total number of lines in the code
SCC
7
SemiColons Count
Total number of semicolon tokens found in the code.
NOT
175
Number Of Tokens
Comments, whitespace and text which cannot be made into a token not included.
VCC
990
Visible Characters Count
The total number of non-white (i.e., not space, tab, newline, carriage return, form feed) characters.
CCC
527
Code Characters Count
Total number of non-white characters in tokens. White space characters in string and character literals are not counted.
UIC
27
Unique Identifiers Count
The number of different identifiers found in the code