Acyclic orientation 2026-10-14
An acyclic orientation is an orientation of a graph whose resulting directed graph has no directed cycle, hence is a Directed acyclic graph. A directed cycle must follow every arrow around its closed route. A cycle in a graph in the skeleton of a directed graph only requires the corresponding undirected edges; their arrows need not agree around the route.
For the same triangle in a graph with vertex set and edges , compareBoth have an undirected cycle in a graph in their skeleton of a directed graph. Only has a directed cycle. In , has no outgoing directed edge, so a route cannot continue from back to .
The same triangle in a graph with an acyclic orientation and an orientation of a graph containing a directed cycle
. Details. Thus an acyclic orientation does not require its underlying undirected graph to be a forest. Every orientation of a graph of a forest is acyclic, because a directed cycle would give an undirected cycle in a graph. Conversely, every finite simple graph, including one with many cycles in a graph, admits at least one acyclic orientation by the following ordering construction. On this triangle in a graph, six of the eight orientations of a graph are acyclic; the other two follow the directed cycle in opposite senses.
Admissible crystallographic Coxeter graph 2026-10-14
In the crystallographic convention, a Coxeter graph is admissible when it is realized by linearly independent unit vectors in a Euclidean space, with nonpositive mutual inner products and for distinct vertices. The number records a single, double or triple connection; equivalently, the displayed Gram matrix is positive-definite. In edge-label notation the nonzero connections have labels . Forgetting multiplicity, the underlying graph is a forest: for any cycle of distinct vertices, the sum of the corresponding unit vectors would have squared norm at most , contradicting their linear independence. Multiple lines on one connection are labels and are not length-two cycles. This is the convention of Wehler's Lie algebra notes, section 6.3.
Breadth-first search Created 2026-09-24 Updated 2026-10-14
Breadth-first search is a graph search that explores successive layers of graph distance from a starting vertex . Here the graph is an undirected graph on a finite set of vertices, and distance counts edges, with no differing edge weights. Mark as discovered, assign , and place it in a FIFO queue. Repeatedly remove the front vertex and scan its adjacency list. Whenever a graph neighbour is still undiscovered, mark it immediately, record as its parent in a rooted tree in the discovery tree, assign , and enqueue at the rear. Marking on insertion ensures that another edge cannot enqueue the same vertex again. [ref]
https://raw.githubusercontent.com/kevin-wayne/algs4/master/src/main/java/edu/princeton/cs/algs4/BreadthFirstPaths.java. Sedgewick and Wayne, Algorithms: BreadthFirstPaths queue and discovery rule
Use the same undirected graph as depth-first search, with vertex set and edgeswhere denotes the unordered pair . Start at and scan graph neighbours in lexicographic order of their one-letter labels. The diagram's generator computes the following layers and the parent in a rooted tree assigned to each discovered vertex; the source is the root of a tree and has no parent in a rooted tree.
| Graph distance from | Vertices in discovery order | Parent in a rooted tree in the same order |
|---|---|---|
| none | ||
The discovery and removal orders both happen to be . After processing , the FIFO queue is : must be processed before the newer . Processing then skips the already discovered and enqueues , giving . Processing adds nothing. Processing discovers , giving ; later sees already marked and leaves its parent in a rooted tree unchanged. The discovery edges are , forming a rooted tree on all seven vertices even though the original graph contains graph cycles. The discovery tree contains six edges; it need not contain every examined edge.
First arrival is shortest because the FIFO queue keeps assigned distances in nondecreasing order, with entries from at most two consecutive layers. While processing distance , newly discovered vertices receive distance and join the rear. If an undiscovered vertex had a shorter graph path, its preceding vertex on that graph path would lie in an earlier layer and would already have discovered it. Thus is the minimum number of edges from to . This is a mathematical induction over the layers, not an assumption about the drawing. Following the parent in a rooted tree backwards at each step gives ; reverse that sequence to obtain the three-edge graph path . is another shortest graph path, but the specified graph neighbour order makes discover first. Changing that order can change the parent in a rooted tree without changing graph distances. [ref]
https://ocw.mit.edu/courses/6-006-introduction-to-algorithms-fall-2011/1208e162775f6f5cedfbb9f2b694ede0_MIT6_006F11_lec13.pdf. MIT 6.006, lecture 13: distance layers and shortest paths, pp. 4–6
The shortest-route guarantee concerns the shortest path problem measured by edge count. It also minimizes total cost when every edge has the same positive cost. With unequal edge weights, first discovery need not minimize total cost; nonnegative costs can instead be handled by the Dijkstra algorithm. Breadth-first search is useful for minimum-hop routes and for finding all vertices within a specified graph distance. Its FIFO queue finishes an older layer before the next one, whereas depth-first search uses a call stack or explicit LIFO stack to pursue one branch immediately.
With adjacency lists and constant-cost discovery checks, together with constant worst-case or amortized analysis cost for FIFO queue insertion and removal, the time complexity is in Big O notation. Every reached vertex is enqueued and removed once, each incident edge is scanned at most twice in an undirected graph, and initializing all marks and distances takes . The FIFO queue contains at most vertices; the example's maximum is three. Discovery marks, distances and the recorded parent in a rooted tree for each nonroot vertex also give auxiliary space complexity, excluding the graph. An array that shifts every entry on front removal can lose the linear time complexity; the FIFO queue abstraction alone does not make removal constant-cost. Ordering the adjacency lists is a separate preprocessing cost.
A single start reaches only its connected component of a graph. Unreached vertices retain distance and have no recorded parent in a rooted tree. Restarting at each still-undiscovered vertex, while preserving all discovery marks, produces a forest covering the graph; each new root of a tree gets distance zero, so these distances refer to that root of a tree, not to the original .
Depth-first search 2026-10-13
Depth-first search is a graph search that follows a branch as far as it can before returning to try the next unexplored branch. Starting at a vertex of an undirected graph on a finite set of vertices, mark as discovered. Scan its graph neighbours in a fixed order: for each undiscovered vertex, record the current vertex as its parent in a rooted tree in the discovery tree, mark the new vertex, and explore it immediately using recursion. Return when its adjacency list is exhausted. Discovery marks persist after return, preventing a graph cycle from causing repeated exploration. This branch-and-return rule is the maze exploration described in MIT's notes. [ref]
Use the same unweighted undirected graph as breadth-first search, with vertex set and edgeswhere denotes the unordered pair . Visit graph neighbours in lexicographic order of their one-letter labels, starting at . The discovery order, computed by the diagram's generator, isThe discovery edges in order are . They form a rooted tree spanning the reached vertices, with root of a tree . The other edges, and , remain in the original graph but never discover a new vertex. In particular, the graph cycle causes no repeated discovery.
At there is no undiscovered graph neighbour, so its call returns to . The next call enters , then , then , then . Immediately after discovering , the call stack is , with on top; is still discovered but its call has finished. The maximum call stack depth is six, although seven vertices are discovered. Following the recorded parent in a rooted tree backwards at each step reconstructs a graph path; here the route from to is , using five edges. Breadth-first search instead finds , using three edges. Depth-first search establishes reachability but does not guarantee the fewest edges.
An explicit LIFO stack can replace recursion, but its entries and discovery rule must be specified. To reproduce this exact traversal, store one frame per active vertex, retaining the next position in its adjacency list. Advance the top frame by one graph neighbour; if that vertex is undiscovered, mark it and push its frame immediately; pop an exhausted frame. Pushing all undiscovered graph neighbours at once and marking them on push is a different iterative variant. Even pushing them in reverse lexicographic order does not generally reproduce the parent in a rooted tree relationships above: would already be marked while processing , so could not discover .
With an adjacency list representation, constant-cost discovery checks and frame operations, and the graph neighbours already ordered, depth-first search has time complexity in Big O notation. Each reached vertex is entered once and each incident edge is examined at most twice in an undirected graph; initializing all discovery marks costs . The call stack has depth at most , since no active vertex repeats. Discovery marks and the recorded parent in a rooted tree for each nonroot vertex also need auxiliary space complexity, excluding storage for the graph. Sorting adjacency lists to obtain a chosen order is additional work. [ref]
https://raw.githubusercontent.com/kevin-wayne/algs4/master/src/main/java/edu/princeton/cs/algs4/DepthFirstPaths.java. Sedgewick and Wayne, Algorithms: DepthFirstPaths discovery marks and resource bounds
One start explores only its connected component of a graph. To cover a disconnected graph, start again at every still-undiscovered vertex while keeping all discovery marks; the discovery trees form a forest. Depth-first search is useful for reachability, constructing a spanning tree of a connected graph, and organizing the return steps needed by a depth-first traversal of a tree. For detecting a graph cycle in a simple graph that is an undirected graph, an edge to an already discovered vertex other than the current parent in a rooted tree closes a graph cycle; the immediate return edge to that parent in a rooted tree is not itself a graph cycle.
// Target: computer-science.bigb
DFS lowpoint 2026-10-14
For a finite simple graph that is an undirected graph, the DFS lowpoint of is the smallest DFS discovery time reachable by following zero or more discovery edges down its rooted tree, then at most one non-discovery edge to an ancestor. Staying at is allowed. Ignore the reverse traversal of the discovery edge to the parent in a rooted tree: it is the same edge, not an escape route. Start with . On returning from a child in a rooted tree , replace by . For a non-discovery edge from to an earlier ancestor , replace it by . This summarizes how far upward the explored branch can reconnect. [ref]
https://sites.cs.ucsb.edu/~gilbert/cs240a/notes/TarjanDFS.pdf. Tarjan (1972), §3, LOWPT recurrence, pp. 151–153
The cut vertex criterion has a separate case for each root of a tree in the discovery forest:
- A nonroot vertex is a cut vertex exactly when some child in a rooted tree satisfies .
- A root of a tree is a cut vertex exactly when it has at least two children in a rooted tree, counting discovery edges, rather than all graph neighbours.
- A discovery edge is a bridge in a graph exactly when . A non-discovery edge is never a bridge in a graph.
Why does equality matter? If , the branch below can reconnect to , so the discovery edge lies on a graph cycle and is not a bridge in a graph. Deleting the vertex destroys that reconnection too. If has a parent in a rooted tree, the branch is then separated from that parent in a rooted tree, explaining the non-strict cut vertex test. For a root of a tree, there is no earlier side to separate from; distinct discovery branches cannot have an edge between them, since depth-first search would have explored them as one branch. This gives the two-children in a rooted tree rule. These are proof outlines of the criteria. [ref]
https://algs4.cs.princeton.edu/41graph/Biconnected.java.html. Sedgewick and Wayne, Biconnected.java: discovery, lowpoint and root tests
[ref]In the joined- example with DFS discovery times , the DFS lowpoints in label order are . For and its child in a rooted tree , : is a bridge in a graph, and is a cut vertex. For and its child in a rooted tree , : is a cut vertex, although is not a bridge in a graph. The root of a tree has only one child in a rooted tree, , so it is not a cut vertex. In the shared- example, the root of a tree has two children in a rooted tree, and , and is a cut vertex, while every DFS lowpoint is and no edge passes the strict bridge in a graph test.
Restart depth-first search at every undiscovered vertex to cover a disconnected graph, applying the root of a tree rule separately in each connected component of a graph. With adjacency lists and constant-cost label operations, computing all DFS lowpoints, cut vertices and bridges in a graph has time complexity in Big O notation, because each vertex is discovered once and each edge is inspected twice. The simple parent-skipping rule assumes a simple graph. In a multigraph, skip only the actual parent edge, identified individually: a parallel edge to the same parent in a rooted tree is a valid reconnection and can prevent the first edge from being a bridge in a graph. The criteria here concern undirected graphs; a directed graph requires a different connectivity analysis.
Forest Created 2026-09-24 Updated 2026-10-14
A forest is an undirected graph with no graph cycle; each of its connected components of a graph is a tree, including any isolated vertex. A finite forest with vertices and connected components of a graph hasIndeed, a connected component of a graph with vertices contributes edges; adding these counts gives . Equivalently, start with isolated vertices: every added edge must join different connected components of a graph, reducing their number by one. Joining vertices already connected would create a graph cycle. [ref]
https://ocw.mit.edu/courses/18-200-principles-of-discrete-applied-mathematics-spring-2024/mit18_200_s24_lec05-06.pdf. MIT, counting notes, p. 4: building forests by merging components
Deleting in our example gives , , and five edges: the two trees contribute . Deleting as well leaves isolated, so and four edges. A forest therefore describes separate hierarchies or the intermediate stages of building a spanning tree. The acyclic graph condition accounts for missing connections without assuming that all locations are mutually reachable.
Graphic matroid 2026-10-14
For a finite undirected graph, the graphic matroid has its edges as the ground set. A subset is a matroid independent set when its edges form a forest on the original vertices, including isolated vertices. Its matroid bases give a spanning tree in each connected component of a graph; for a connected graph, each matroid basis is a spanning tree.
For a graph triangle on vertices , label the edges , , and , with weights . The empty set, all singletons, and all pairs are forests; the triple contains the graph cycle . Thus its eight subsets have exactly the independence pattern checked in the weighted three-vector matroid, and the same fifteen exchange comparisons pass. The matroid greedy algorithm chooses , chooses , and rejects , producing the heaviest spanning tree, of weight .
A weighted graph triangle admits greedy selection of a matroid basis; a hereditary independence system without exchange traps a greedy algorithm at weight instead of
. Details. Exchange outline. Deleting edges cannot create a graph cycle. If forests have , some edge of joins different connected components of a graph of : otherwise, within each such component, would have at most its number of vertices minus one edges, giving . Adding that edge keeps a forest. This is the matroid independence axioms expressed through connectivity.
Labelled forest count with prescribed roots 2026-10-14
For a fixed set of roots among labelled vertices, the number of forests with exactly one root in each graph component is . Orient edges toward their roots. Repeatedly remove the smallest nonroot leaf and record its parent. This gives a code of length whose last entry is a root. Conversely, for any such code choose the smallest remaining nonroot absent from the remaining code, join it to the first entry, and delete it. There is always a choice because the final entry is a root. These inverse operations give choices for the earlier entries and for the last. For , the empty forest is unique.
Matroid Created 2026-10-13 Updated 2026-10-14
A matroid is an independence system in which a smaller admissible selection can always grow using an element of a larger admissible selection. This exchange rule abstracts linear independence of vectors and the selection of edges forming a forest. It forces all matroid bases to have the same cardinality and makes the matroid greedy algorithm correct for maximizing their total weight. The useful surprise is that local choices become globally optimal because of a structural rule about admissible subsets, rather than a special numerical coincidence.
The weighted three-vector matroid below lets us inspect every subset and every possible size comparison. Its three vectors give three two-element matroid bases, yet their total weights differ. The graphic matroid of a graph triangle has exactly the same admissible labels. A pregeometry is a finitary closure-theoretic extension to possibly infinite sets.
Past exam of the mathematics course of the University of Cambridge 2002 iii Paper 28 2 Solution Created 2026-10-03 Updated 2026-10-14
Use the contact process convention that each infected vertex recovers at rate one and sends infection arrows to each neighbour at rate . Starting from a finite set, the process stays finite and is nonexplosive: its total birth rate is at most times its current size, so a linear-rate branching process dominates the number of births. The bound involving presupposes the branching-tree case .
For a nonempty finite infected set , put , let count its internal edges, and let count edges with exactly one endpoint in . Each such boundary edge contributes infection rate , even when several lead to the same vacant vertex. Since the induced graph is a forest, , and the edge boundary of a finite forest in a regular tree givesA recovery multiplies by , while an infection multiplies it by . Therefore its infinitesimal generator isSubstituting the boundary lower bound givesAt the absorbing empty set the generator is zero, rather than this nonempty-set expression. If , the generator is nonpositive in every state. Both and its generator are bounded, since is bounded and . Applying Dynkin's formula over successive time intervals with the Markov property proves the exponential cardinality supermartingale for the contact process on a tree. In particular,If is the extinction time, , so . Choosing proves global survival whenever . Obtaining a strict improvement of the threshold requires an additional comparison.
Here is a two-vertex branching comparison for contact-process survival. Delete one edge incident to a starting vertex and retain its forward rooted subtree, so every vertex has children. Partition it into cells as follows: pair each cell root with one distinguished child ; the other children of and all children of become roots of child cells, and repeat recursively. Each cell thus has child cells.
Suppress arrows back from a child cell into its parent, allow each child cell to be activated only once, and let infection inside each two-vertex cell evolve with the usual recoveries and reinfections until both vertices are healthy. A child cell is activated at its root by the first outgoing arrow to it while the corresponding parent vertex is infected. This process is contained in the original infection process under the graphical representation of the contact process: only infection paths have been removed. The Poisson clocks inside a child cell and on its outgoing edges have not previously been used. The Strong Markov property and independence of the clocks therefore make different cells' offspring counts independent and identically distributed. Dependence among different children of the same cell does not matter. The cell genealogy is a Galton-Watson process.
Let be the probability that a cell, initially infected only at , sends an arrow along one specified outgoing edge from before internal extinction. Let be the corresponding probability for one specified outgoing edge from , and let be the probability of success for the first target when both cell vertices are initially infected. First-step conditioning on the three nonempty pair states givesFor example, from the state with only infected, recovery at rate one fails, an internal arrow at rate leads to the two-infected state, and the target arrow at rate succeeds. From the state with only infected, the target cannot be reached until is infected. Symmetry identifies this latter success probability with . Solving these equations yieldsBy linearity of expectation, the offspring mean is . At the comparison rate ,These finite-state probabilities are continuous in . Hence some still has . The branching-process extinction criterion gives positive probability of infinitely many activated cells. Nonexplosion prevents infinitely many activations in bounded time, and each activation is connected to its ancestor by an infection path. Thus infection survives for all time on that event. The global survival threshold of the contact process consequently satisfiesRetaining reinfection inside pairs is what supplies the strict improvement; a comparison that permits only one infection per vertex would give merely the non-strict bound.
For the local-survival estimate, set and . Each vertex has one neighbour of weight and neighbours of weight . Recoveries remove their vertex weights. Ignoring the restriction that an infection target must be vacant only increases the birth contribution, soThese weights have finite expectations on finite time intervals: a birth-only branching process with the same spatial arrows has expected weight at most . This justifies localization and the expectation identity for the generator. If , Dynkin's formula and the integrating-factor form of the Gronwall inequality giveFor , take , which minimizes and makes it . Starting from then givesIn particular the expected total occupation time of is finite. Its recovery clock has rate one, so the expected number of recovery marks that occur while is infected equals this occupation-time integral and is finite. Each infection episode ends almost surely at a recovery. Infection at unbounded times would therefore require infinitely many such recoveries, an event of probability zero. This height-weighted local extinction bound for the contact process provesThis is a bound for the local survival threshold of the contact process, not just a bound on single-time infection probabilities. For the degree-two tree , the same local conclusion follows by choosing sufficiently close to one for each ; the displayed expression for the global threshold is not a finite numerical assertion in that case.
Past exam of the mathematics course of the University of Cambridge 2003 iii Paper 12 4 i Solution Created 2026-10-03 Updated 2026-10-14
We first establish the labelled forest count with prescribed roots. For a prescribed root set of size , orient each tree toward its unique root. Repeatedly delete the smallest remaining nonroot leaf, recording its parent. There are deletions, and the final recorded parent belongs to . Conversely, start with any code of length whose last entry lies in . At each step select the smallest remaining nonroot absent from the remaining code, connect it to the code's first entry, and delete that vertex and entry. Such a vertex exists: among remaining nonroots, the remaining code has entries but at least its last entry is a root, so at most nonroots occur in it. Previously deleted vertices never recur in the code, so the selected parent is still present. Every edge goes from a vertex being deleted to one retained, excluding a cycle. The resulting forest has one root in each graph component, and the two constructions are inverse. Its count is thereforefor , interpret this as one, the empty forest.
A connected simple graph with edges has exactly one cycle: a spanning tree uses edges, and the remaining edge creates its unique cycle. If that graph cycle has length , choose its vertex set in ways and its unoriented cyclic order in ways. All other edges form a forest rooted at those vertices, with exactly one cycle vertex per forest component; two roots in one attached component would create an additional cycle. Conversely every such cycle and rooted forest gives a unique unicyclic component. ThusThis is the labelled unicyclic graph count. The term correctly counts a cycle with no attached nonroot vertices.
Past exam of the mathematics course of the University of Cambridge 2004 iii Paper 33 3 Solution Created 2026-10-03 Updated 2026-10-14
For a connected undirected weighted graph, a spanning tree connects all vertices without a graph cycle. A minimum spanning tree minimizes the sum of its edge weights. Disconnected input has no spanning tree, although the same methods produce a minimum spanning forest. Negative edge weights and ties cause no difficulty; a tree always contains exactly edges.
The central exchange argument is the minimum spanning tree cut property. Suppose a forest is contained in some minimum spanning tree , and consider a cut with no edge of crossing it. Let be a lightest crossing edge. If , adding it creates a graph cycle; the graph path in between its endpoints contains a crossing edge . That is not in , and . Thus is another spanning tree with no larger weight and still contains . It is also minimum and contains . This proves that the chosen edge is safe, rather than merely asserting a greedy choice.
Kruskal's algorithm sorts all edges by increasing weight, starts with the empty forest, and adds an edge precisely when its endpoints are in different components. Each added edge is lightest across a component cut respected by the current forest. The exchange proof inductively keeps the forest inside a minimum spanning tree; connectedness makes the final forest a spanning tree, hence an optimum. Sorting takes comparisons, and even a simple component-merging implementation takes only polynomial additional work. Efficient component tracking improves that overhead further.
Prim's algorithm instead grows a single tree, repeatedly adding a lightest edge from its vertex set to the outside. The same cut argument proves correctness. A dense implementation using an array runs in comparisons. The dual minimum spanning tree cycle property says a uniquely heaviest edge of a graph cycle belongs to no minimum spanning tree: exchanging it for a lighter crossing edge strictly improves any tree containing it. Ties must be handled carefully; a merely nonunique heaviest edge can occur in an optimum.
Complexity classes are formally classes of decision problems, so use the version asking whether a graph has a spanning tree of total weight at most a supplied threshold . Assume integer or rational weights and threshold are encoded in binary. The input length includes all these bits, not only the numbers of vertices and edges. P consists of decision problems decidable by a deterministic algorithm in time polynomial in that input length. NP consists of those with polynomial-size complexity certificates verified in deterministic polynomial time, equivalently decidable in polynomial time by a nondeterministic machine.
Kruskal's algorithm constructs the optimum and compares its weight with . Binary integer comparisons and sums are polynomial-time operations. Rational comparisons can be made by cross multiplication, and their summed numerator and denominator have polynomially bounded bit length: a product of input denominators has bit length no greater than the sum of their bit lengths. The combinatorial algorithm makes polynomially many such operations. Hence the minimum-spanning-tree decision problem is in P; the optimization version likewise has a polynomial-time algorithm.
For membership in NP, the complexity certificate is a list of selected edges. Check that every edge is present, that the edges connect all vertices and contain no graph cycle, and that their total weight is at most . A graph search and binary arithmetic do this in polynomial time. A successful complexity certificate need not establish that its tree is minimum: it proves the threshold question's yes-answer. Conversely, a yes-instance has such a tree as a complexity certificate. ThereforeMembership in NP does not arithmetic mean NP-hardness; here the explicit greedy algorithm provides the stronger tractability result.



