Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Class LongestWalkProcessor

Ori Roth edited this page Apr 2, 2017 · 3 revisions

Synopsis of Class LongestWalkProcessor

public class LongestWalkProcessor<Data> extends EmptyProcessor<Data, int[]> { 
    /*
     * Forge (1)
     */
        LongestWalkProcessor(); 
    /*
     * Type (3)
     */
        void before(Graph<Data> g); 
        void after(Vertex<Data> v); 
        int[] after(Graph<Data> _); 
} 

Input types: Comparable<Data>, Graph<Data>, Vertex<Data>.

Code

// SSDLPedia
package il.ac.technion.cs.cs236700.graph;

import static java.lang.Math.max;
import il.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
 */
public class LongestWalkProcessor<Data extends Comparable<Data>> extends EmptyProcessor<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.
     */
    private int[] result;
    
    @Override public void before(final Graph<Data> g) {
        result = new int[g.vertices.length];
    }
    
    @Override public void after(final Vertex<Data> v) {
        for (final Vertex<Data> u : v.to)
            if (u != v)
                result[v.i] = max(result[v.i], 1 + result[u.i]);
    }
    
    @Override public int[] after(@SuppressWarnings("unused") final Graph<Data> _) {
        return result;
    }
}

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
WHC 2 Weighted Horizontal Complexity A heuritistic on horizontal complexity

Statistics

Statistic Value
Average token length 3
Tokens/line 4.6
Visible characters/line 26
Code characters/line 14
Semicolons/tokens 4%
Comment text percentage 46%

Tokens by kind

Token Kind Occurrences
KEYWORD 26
OPERATOR 17
LITERAL 2
ID 63
PUNCTUATION 67
COMMENT 3
OTHER 69
Clone this wiki locally
Morty Proxy This is a proxified and sanitized view of the page, visit original site.