ccomps
Find connected components in a graph
TLDR
Decompose one or more graphs into their connected components
Print the number of nodes, edges, and connected components in one or more graphs
Write each connected component to numbered filenames based on output.gv
Display help
SYNOPSIS
ccomps [-oxfile] [-s] [-v] [files]
PARAMETERS
-oxfile
Writes to xfile a list of "component node" pairs, one per line.
-s
Uses set data structures internally; ~30% more memory but faster on some graphs/machines.
-v
Enables verbose mode; multiple -v increases detail.
DESCRIPTION
ccomps is a Graphviz utility that analyzes directed or undirected graphs to find and label their connected components. It reads input graphs in standard formats like DOT and assigns each node a unique integer label corresponding to its component, discovered via randomized DFS or BFS traversal. The modified graph, with added label attributes on nodes, is output to stdout.
On the first line of output, it prints 1 if the graph is undirected or 0 if directed. For directed graphs, components are weakly connected (edge directions ignored). This enables graph partitioning, structure analysis, or preprocessing for tools like dot.
Supports multiple input files or stdin. Ideal for large graphs in network analysis, software dependency mapping, or visualization prep. Component numbers are arbitrary, not ordered by size or discovery.
CAVEATS
Component labels are arbitrary. Treats digraphs as weakly connected. Requires Graphviz installed.
OUTPUT DETAILS
First line: graph directedness (1=undirected, 0=directed).
Graph output includes per-node label="comp#".
EXIT STATUS
Returns 0 on success, 1 on error (e.g., invalid input).
HISTORY
Developed as part of Graphviz at AT&T Bell Labs (late 1990s); evolved through open-source releases, now at version 12+ with performance tweaks.


