Skip to content

Contents

Each chapter starts with a page that explains its ideas; the problems follow. To find a problem by the function that solves it, see the index by API; to find a word, use the search at the top of the page.

1 Building and reading graphs

This chapter shows how a graph comes into being, where its data lives, and how to read its nodes and edges.

2 Order and cycles

This chapter finds orders in which every node comes before its out-nodes, and the cycles that prevent them.

3 Strongly connected components

This chapter shows where the cycles of a directed graph are, and which nodes reach each other through them.

4 Reachability and distances

This chapter answers which nodes a node reaches, which nodes reach it, and how many edges lie in between.

5 Connectivity when direction does not matter

This chapter reads graphs as undirected: their weakly connected components, the edges and nodes whose removal splits a component, their biconnected components, and whether they are bipartite, trees or forests.

6 Trees and hierarchies

This chapter covers trees and forests: their shape, the parent and depth of each node, ancestors, lowest common ancestors, and the descendants of a node.

7 Dominance

This chapter finds the nodes that every path from an entry passes through, the tree they form, the same towards an exit, and dominators from several entries.

8 Control-flow analysis

This chapter shows the graph of the paths through a function, and what compilers and analyzers read from it: loops, dominance frontiers, phi-nodes and control dependence.

9 Transforming graphs and carrying data along

This chapter derives subgraphs, renumbered and transposed graphs, and groups of your own from a graph, and shows how the data on nodes and edges follows them.

10 Storing and comparing graphs

This chapter saves graphs to files and loads them again, recognizes a graph that has not changed, and compares two versions edge by edge.

11 Showing graphs

This chapter turns graphs into text for logs and tests, and into pictures drawn by Graphviz and by Mermaid, with labels, styles and frames from your own data.

12 Writing searches of your own

This chapter shows how to write your own depth-first and breadth-first searches on Graphity's traversers without recursion, and how to loop over the arrays of a graph.