LinuxCommandLibrary

scc

Count lines of code in files

TLDR

Print lines of code in the current directory

$ scc
copy

Print lines of code in the target directory
$ scc [path/to/directory]
copy

Display output for every file
$ scc --by-file
copy

Display output using a specific output format (defaults to tabular)
$ scc [[-f|--format]] [tabular|wide|json|csv|cloc-yaml|html|html-table]
copy

Only count files with specific file extensions
$ scc [[-i|--include-ext]] [go,java,js]
copy

Exclude directories from being counted
$ scc --exclude-dir [.git,.hg]
copy

Display output and sort by column (defaults to by files)
$ scc [[-s|--sort]] [files|name|lines|blanks|code|comments|complexity]
copy

Display help
$ scc [[-h|--help]]
copy

SYNOPSIS

scc < input_graph

DESCRIPTION

The `scc` command identifies and outputs the strongly connected components (SCCs) within a directed graph. It reads the graph structure from standard input, where each line represents an edge specified by two vertex numbers separated by whitespace. The command then computes the SCCs using a standard graph traversal algorithm (e.g., Kosaraju's algorithm or Tarjan's algorithm). The output consists of a list of SCCs, with each SCC represented by a list of vertices belonging to that component. This utility is useful for analyzing dependencies, identifying circular references, and understanding the overall structure of complex systems modeled as directed graphs. It finds applications in areas like compiler design (dependency analysis), network analysis, and software engineering (analyzing module dependencies). Note: While similar names may exist for source code counting tools (e.g., `sloccount`), this definition focuses on the graph-theoretical SCC analysis tool often included within graph processing suites.

CAVEATS

The `scc` command typically expects vertex numbers to be integers. Input graphs should be formatted correctly with space-separated vertices for each edge. Error handling for invalid input might be minimal.

INPUT FORMAT

The input graph must be represented as a list of edges on standard input. Each line represents one edge, with the source and destination vertices separated by whitespace. For example:
1 2
2 3
3 1
4 5
This input represents a graph with edges from vertex 1 to 2, 2 to 3, 3 to 1, and 4 to 5.

OUTPUT FORMAT

The output is a list of strongly connected components. Each component is represented by a list of vertices belonging to that component, typically enclosed in parentheses or braces and separated by spaces or commas. The order of components and vertices within each component may vary. For example, for the example graph in "Input Format", an example output might be:
{1, 2, 3}
{4, 5}

SEE ALSO

acyclic(1), components(1), transitive_closure(1)

Copied to clipboard