User:JMP EAX/draft merge

In mathematics, and, in particular, in graph theory, a rooted graph is typically defined as a (undirected) graph in which one node is labelled in a special way to distinguish it from the graph's other nodes. This special node is called the root of the graph. A special case of interest are rooted trees.

As commonly defined, particularly in computer science, rooted directed graph or rooted digraph is a more specialized notion than simply identifying a root r—there must also be a directed path from r to any node other than r. Flow graph (also spelled flowgraph) is another synonym used in computer science for this notion,  and is the common one in programming language theory.

In his seminal work on non-well-founded sets, Peter Aczel uses pointed graph to refer to a digraph that has a single distinguished node, and accessible pointed graph in the case where all other nodes in the digraph can be reached from the distinguished one. This latter terminology has been adopted by other authors in mathematical logic and logic in computer science.

Rooted (undirected) graphs
The number of rooted graphs for 1, 2, ... nodes is 1, 2, 6, 20, 90, 544, ...

Rooted graphs may be combined using the rooted product of graphs.

In topological graph theory, the notion is extended to consider multiple nodes (vertexes) or multiple edges as roots. The former are sometimes called vertex-rooted graphs in order to distinguish them from edge-rooted graphs in this context. Graphs with multiple nodes designated as roots are also of some interest in combinatorics, in the area of random graphs.

As flow graphs
A flow graph is essentially an abstraction obtained from the notion of flow chart, with the non-structural elements (like node contents and types) removed.

Perhaps the best know sub-class of flow graphs are control flow graphs (CFG), used in compilers and program analysis. An arbitrary flow graph may converted to a CFG by performing an edge contraction on every edge whose source node has outdegree 1 and whose target node has indegree 1. Another type of flow graph commonly used is the call graph, in which nodes correspond to entire subroutines.

The general notion of flow graph has been called program graph, but the same term has also been used to denote just CFGs. Flow graphs have also received a number of qualified synonyms (perhaps indented to disambiguate them from CFGs), including unlabeled flowgraphs, and proper flowgraphs. Flow graphs (rather than CFGs) are sometimes used in software testing.

TODO: Introduce reducible flow graphs about here.

In the theory of structured programming, an additional restriction is added specifying that a flow graph must have a single exit (sink) vertex as well. When enriched with the single-exit property, flow graphs have two properties not shared with directed graphs in general. Flow graphs can be nested, which is the equivalent of a subroutine call (although there is no notion of passing parameters), and flow graphs can also be sequenced, which is the equivalent of sequential execution of two pieces of code. Prime flow graphs are defined as flow graphs that cannot be decomposed via nesting or sequencing using a chosen pattern of subgraphs, for example the primitives of structured programming. Theoretical research has been done on determining, for example, the proportion of prime flow graphs given a chosen set of graphs.

More than one root
The Art of Computer Programming defines rooted digraphs slightly more broadly, namely a directed graph is called rooted if it has at least one node that can reach all the other nodes; Knuth notes that the notion thus defined is a sort of intermediate between the notions of strongly connected and connected digraph. In a finite graph, the existence of such a vertex can be tested in linear time: it exists if and only if the condensation of the graph has exactly one vertex with no incoming edges. If so, the root can be chosen as any vertex in the strongly connected component corresponding to this vertex.

Other applications
Accessible pointed graphs are used in Aczel's anti-foundation axiom, where they model the membership structure of sets in a non-well-founded set theory.

They also form the inputs for computational problems of finding an optimal spanning arborescence, that is, a rooted tree containing all vertices of a given directed graph, with all edges directed from the root towards the leaves. Such a tree exists exactly when the input is accessible and pointed.