  Cyclomatic complexity is an incompletely specified but mathematically
principled software metric that can be usefully applied to both source and
binary code. We consider the application of path homology as a stronger
analogue of cyclomatic complexity. We have implemented an algorithm to compute
path homology in arbitrary dimension and applied it to several classes of
relevant flow graphs, including randomly generated flow graphs representing
structured and unstructured control flow. We also compared path homology and
cyclomatic complexity on a set of disassembled binaries obtained from the grep
utility. There exist control flow graphs realizable at the assembly level with
nontrivial path homology in arbitrary dimension. We exhibit several classes of
examples in this vein while also experimentally demonstrating that path
homology gives identicial results to cyclomatic complexity for at least one
detailed notion of structured control flow. We also experimentally demonstrate
that the two notions differ on disassembled binaries, and we highlight an
example of extreme disagreement. Path homology empirically generalizes
cyclomatic complexity for an elementary notion of structured code and appears
to identify more structurally relevant features of control flow in general.
Path homology therefore has the potential to substantially improve upon
cyclomatic complexity.
