Glossary
Adjacency list
Section titled “Adjacency list”An adjacency list is a graph written as one line per node. Each line holds a node and its
out-nodes, such as 1 -> [3, 4, 6].
Ancestor and descendant
Section titled “Ancestor and descendant”In a tree or forest, a node a is an ancestor of a node b if a lies on the
path from the root to b. Then b is a descendant of a. In this guide and
in Graphity, a node is its own ancestor and its own descendant.
Basic block
Section titled “Basic block”A basic block is a stretch of code that runs from top to bottom. No jump leads into it or out of it, except at its start and at its end. The nodes of a control-flow graph are basic blocks.
Biconnected component
Section titled “Biconnected component”A biconnected component is a group of edges in which any two edges lie on a common cycle of the undirected reading. The group is as large as it can be. A biconnected component is also called a block. Its nodes stay connected if any one of them is removed.
Bipartite
Section titled “Bipartite”In the undirected reading, a graph is bipartite if its nodes split into two sets so that every edge runs from one set to the other.
Breadth-first search
Section titled “Breadth-first search”A breadth-first search (BFS) visits the nodes in the order of their distance from its start node. With several start nodes, the distance counts from the nearest one. The search visits the start nodes first, then the nodes one edge away, then those two edges away, and so on.
Bridge and articulation point
Section titled “Bridge and articulation point”In the undirected reading, a bridge is an edge whose removal increases the number of connected components. An articulation point is a node whose removal does the same.
Condensed graph
Section titled “Condensed graph”A condensed graph has one node for each group of a partition of the nodes.
It has an edge g -> h wherever an edge of the original graph runs from a node in group g to a
node in group h. Edges inside a group are left out. The edges from one group to another become one
edge. The condensed graph of the strongly connected components is
a DAG (directed acyclic graph).
Control dependence
Section titled “Control dependence”A block is control dependent on a branch if the outcome of the branch decides whether the block runs.
Control-flow graph
Section titled “Control-flow graph”A control-flow graph (CFG) is the graph of the paths that the execution of a function can
take. It has a node for each basic block. It has an edge a -> b if execution can
continue with block b after block a.
CSR layout
Section titled “CSR layout”The CSR layout (compressed sparse row) is a way to store a graph in two arrays. One array holds the out-nodes of all nodes, node after node. The other holds the position where the out-nodes of each node start, followed by the number of edges. Graphity keeps every graph this way.
A cycle is a path of edges that leads from a node back to the same node, such as
a -> b -> c -> a. The shortest cycle is a self-loop, which is an edge from a node to
itself. In the undirected reading, a cycle uses no edge twice, and a -> b
and b -> a count as one undirected edge. So going along an edge and back is no cycle.
A DAG (directed acyclic graph) is a directed graph without a cycle. Its nodes can be put in an order in which every edge points forward. Such an order is a topological order.
In a tree or forest, the depth of a node is the number of edges from the root to the node. A root has depth 0.
Depth-first search
Section titled “Depth-first search”A depth-first search (DFS) goes from a node as deep along outgoing edges as it can before it turns back. The edges it meets are tree, back, forward or cross edges.
Distance
Section titled “Distance”The distance from a node a to a node b is the number of edges on a shortest path from
a to b. A node has distance 0 from itself. A node that is not reached has no distance.
Dominance frontier
Section titled “Dominance frontier”The dominance frontier of a block d holds every block m such that d dominates
an in-node of m but does not strictly dominate m. The iterated
dominance frontier of a set of blocks starts with their dominance frontier. It then adds the
dominance frontier of each block in it, and so on until no block is added.
Dominator
Section titled “Dominator”A node d dominates a node n if every path from an entry to n
passes through d. Every node dominates itself. A node d strictly dominates n if it dominates
n and is not n. The nearest strict dominator of n is its immediate dominator. The immediate
dominators form the dominator tree. A node p post-dominates n if every path from n to an exit
passes through p.
Edge index
Section titled “Edge index”The edge index is the number of an edge. The edges of a graph are numbered from 0 in the order of their source and then their target. Data on edges is kept in arrays indexed by edge index.
Entry and exit
Section titled “Entry and exit”An entry of a graph is a node where the paths of interest start. In a control-flow graph, the entry is the block where the function starts. A graph can have several entries, such as the entry points of a program. An exit is a node where the paths of interest end. In a control-flow graph, an exit is a block where the function returns.
A leaf is a node without out-nodes: it has no outgoing edges. In a tree, a leaf is a node without children.
In a DAG, the level of a node is the number of edges on a longest path to it from a root node. Nodes of the same level of a DAG have no path between them. In a breadth-first search, the level of a node is its distance from the nearest start node.
In a control-flow graph, a loop is a set of blocks that execution can run through again and again. Every block of a loop lies on a cycle through its header. The body of a loop is its header with the other blocks of the loop. These include the blocks of the loops nested in it. Loops nest: a loop can lie in the body of another loop.
Loop header
Section titled “Loop header”The header of a loop is the block through which the loop is entered. It is usually where
the test of a for or while loop sits. A loop that can be entered at more than one block is
irreducible. Graphity then takes as its header the one of these blocks that a
depth-first search from the entry reaches first. The
entries of a loop are the blocks at which execution can enter it from outside. They are its header
and, in an irreducible loop, other blocks as well.
Lowest common ancestor
Section titled “Lowest common ancestor”The lowest common ancestor (LCA) of two nodes is the deepest node that is an ancestor of both.
Mapping
Section titled “Mapping”A mapping is a list that says which node or edge of the original graph each node or edge of a transformed graph comes from. A mapping can also go the other way round. A mapping is partial if some of its entries have no counterpart.
Natural loop
Section titled “Natural loop”A natural loop is a loop that is entered only through its header. Every
loop written with for or while is a natural loop.
Neighbor
Section titled “Neighbor”A neighbor of a node is a node connected to it by an edge in either direction. It is an out-node or an in-node of that node.
Node ID
Section titled “Node ID”The node ID is the number of a node. The nodes of a graph are numbered from 0 to the node count minus 1. Data on nodes is kept in arrays indexed by node ID.
Out-degree and in-degree
Section titled “Out-degree and in-degree”The out-degree of a node is the number of its out-nodes. Its in-degree is the number of its in-nodes. Their sum is called the degree. It is the number of edges at the node, and a self-loop counts twice.
Out-node and in-node
Section titled “Out-node and in-node”The out-nodes of a node a are the targets of its
outgoing edges: the nodes b with an edge a -> b. Its in-nodes are
the sources of its incoming edges. A GraphGraphGraphGraph stores the out-nodes of every node; a
BiAdjacentGraphBiAdjacentGraphBiAdjacentGraphBiAdjacentGraph stores the in-nodes as well.
Outgoing and incoming edge
Section titled “Outgoing and incoming edge”The outgoing edges of a node are the edges with the node as their source. Its incoming edges are the edges with the node as their target. A self-loop is both. In the API, they are called out-edges and in-edges.
Parent and child
Section titled “Parent and child”In a tree or forest, the parent of a node is its single in-node. The node is a child of its parent.
Partition and group
Section titled “Partition and group”A partition is a division of the nodes or the edges of a graph into groups. Each node or edge is in at most one group. A group is known by its group ID. The strongly connected components are a partition of the nodes. The biconnected components are a partition of the edges.
A path is a sequence of edges in which each edge starts where the one before it ends. It leads from the source of its first edge to the target of its last edge. A graph is a path if it is a tree in which every node has at most one out-node. Its edges then form one path through all its nodes. The empty graph counts as a path.
A node a reaches a node b if a path of edges leads from a to b. Every node reaches
itself.
Root node
Section titled “Root node”A root node is a node without in-nodes: it has no incoming edges. Examples are the root of a tree and the first steps of a plan.
Self-loop
Section titled “Self-loop”A self-loop is an edge from a node to itself, such as a -> a.
Source and target
Section titled “Source and target”An edge a -> b runs from its source a to its target b.
SSA form and phi-node
Section titled “SSA form and phi-node”SSA form (static single assignment) is a form of code in which every variable is assigned exactly once. Where different assignments meet, a phi-node picks the value of the path that was taken.
Strong bridge and strong articulation point
Section titled “Strong bridge and strong articulation point”A strong bridge is an edge whose removal increases the number of strongly connected components. A strong articulation point is a node whose removal does the same.
Strongly connected component
Section titled “Strongly connected component”A strongly connected component (SCC) is a group of nodes in which every node reaches every other. The group is as large as it can be. Every node is in exactly one SCC. A node on no cycle is an SCC of its own.
Subgraph
Section titled “Subgraph”A subgraph is a graph made of some of the nodes of a graph and edges between them. Graphity takes the subgraph induced by the nodes it keeps: every edge between them stays. It numbers the nodes of a subgraph anew from 0, in ascending order of their old node IDs. A mapping gives the old node ID of each new node.
Subtree and preorder
Section titled “Subtree and preorder”The subtree of a node is the node with all its descendants. A preorder lists the nodes of a tree in the order in which a depth-first search from its root reaches them. Each node comes before the subtrees of its children, and these follow one after the other. The preorder of a forest lists one tree after the other. So every node comes before its descendants, and each subtree takes a range of consecutive positions.
Topological order
Section titled “Topological order”A topological order is an order of the nodes of a DAG in which the source of every edge comes before its target.
Transitive closure and reduction
Section titled “Transitive closure and reduction”The transitive closure of a graph has an edge u -> v wherever a path of one or more
edges leads from u to v. A node has a self-loop in it exactly when the node lies
on a cycle. The transitive reduction of a DAG keeps an edge u -> v only if no
other path leads from u to v.
Transposed graph
Section titled “Transposed graph”The transposed graph of a graph has the same nodes and every edge turned around: a -> b becomes
b -> a. The nodes that reach a node in a graph are the nodes that it reaches in the
transposed graph.
Tree and forest
Section titled “Tree and forest”A forest is a graph without cycles in which every node has at most one in-node. This in-node is the parent of the node. So the edges point away from the root nodes. A tree is a forest with at most one root node. The empty graph counts as a tree. In the undirected reading, a forest is a graph without cycles. A tree in that reading is a forest that is connected. Graphity’s checks for them ignore self-loops.
Tree, back, forward and cross edge
Section titled “Tree, back, forward and cross edge”A depth-first search meets four types of edges:
- A tree edge leads to a node the search had not seen yet.
- A back edge leads back to a node on the current path and closes a cycle.
- A forward edge leads to a node that the search has already reached from the edge’s source along one or more tree edges.
- A cross edge leads to a node that the search has already finished and that is neither an ancestor nor a descendant of the edge’s source.
Undirected reading
Section titled “Undirected reading”The undirected reading treats a directed graph as if its edges had no direction. An edge a -> b
connects a and b, and a -> b and b -> a count as one undirected edge. A
self-loop is still a cycle of its own, but the methods for this reading
ignore it. The checks for trees and forests do not count it. It is never a
bridge, and it lies in no
biconnected component. The one exception is the test for a
bipartite graph: a self-loop makes a graph not bipartite.
Weakly connected component
Section titled “Weakly connected component”A weakly connected component is a group of nodes that paths connect when the direction of the edges does not matter, as in the undirected reading. The group is as large as it can be. In a graph that stands for an undirected one, it is simply called a connected component.