Adjacency list edge conventions 2026-10-14
For a directed graph, store in for the edge . The reverse edge is separate and is stored only if it exists. Consequently, list length is outdegree, not indegree, and each directed edge contributes one entry in total. An incoming-list index is additional storage.[ref]
Digraph.java. Digraph.java, addEdge, adj and outdegree: one entry in the tail's collection; indegree is maintained separately
Orient the seven edges of our example from earlier to later labels. The resulting directed graph hasThere are now seven entries, with outdegrees . In particular, needs an empty list even though it is reached from : incoming edges do not make 's outgoing list nonempty. Replacing each directed edge by an undirected graph connection would lose this distinction.
Our running simple graph excludes self-loops and repeated edges. If those restrictions are relaxed, specify how the adjacency list encodes them. Here an undirected self-loop at contributes two copies of to , matching its contribution of two to the degree of a vertex. A directed self-loop contributes one copy, and one each to outdegree and indegree. Distinct parallel edges retain distinct entries; a multigraph's list length can therefore exceed its number of distinct neighbours.[ref]
Graph.java. Graph.java, class documentation: parallel edges and two-entry undirected self-loop convention; addEdge applies both insertions even when v equals w
[ref]Digraph.java. Digraph.java, class documentation and addEdge: parallel edges permitted; a directed self-loop adds one outgoing entry and increments indegree once
For example, add one undirected self-loop at to the seven-edge example. Its list becomes , the vertex degree of becomes four, and the total entry count becomes sixteen for eight edges. If an application instead stores a self-loop once, it must account for its doubled undirected vertex degree separately. In a weighted graph, an entry can be an ordered pair meaning destination and weight ; the weight belongs to the edge, not to the destination vertex.
Full ternary tree 2026-10-25
A rooted tree in which every internal vertex has exactly three tree children. For a finite rooted tree with tree leaves and internal outdegrees , counting edges in two ways givesIndeed, the number of edges is the total number of vertices minus one and also the sum of the internal outdegrees. Thus a full ternary tree with internal vertices has tree leaves, always an odd number. More generally, if every internal vertex has either two or three tree children, . This parity controls the initial merge in ternary Huffman coding.
Neighbour enumeration 2026-10-14
Neighbour enumeration reports the neighbours of a specified vertex. For a simple graph, scan its adjacency list and report each entry. With constant-time list access and work per entry, a list of length needs time in Big O notation, conventionally written for nonempty lists. Use vertex degree for an undirected graph and outdegree for a directed graph. Obtaining the list reference can take constant time; consuming it requires visiting every entry.[ref]
Digraph.java. Digraph.java, class documentation and adj: obtaining the collection versus iterating in time proportional to outdegree
In our undirected example, enumerating 's neighbours reads : three entries. Scanning row of the full adjacency matrix reads six entries, , to produce the same answer. In the directed variant, enumerating 's outgoing neighbours reads no neighbour entries, but still needs constant work to locate and recognize its empty list. For a multigraph, scanning lists enumerates incident edges with multiplicity; reporting only distinct neighbours additionally requires removing repetitions.
For a short time complexity argument, each reported entry requires at least one output operation, and one scan suffices. Across all vertices, the undirected entry count is by the handshaking lemma; the directed count is . A graph search that processes each vertex once and scans each of its entries once therefore does structural work, provided its visited-state access and FIFO queue or stack operations also have the required constant-time costs. With a full adjacency matrix, scanning every row instead inspects entries. This is how the representation enters the analysis of breadth-first search and depth-first search.
Outdegree orientation criterion Created 2026-10-07 Updated 2026-10-14
A finite undirected graph can be oriented with outdegree at least an integer at every vertex if and only if every vertex subset is incident to at least distinct edges. The max-flow min-cut theorem and integral max-flow theorem prove sufficiency by assigning distinct edges to vertices through an incidence flow network; each assigned edge is oriented away from that vertex. Necessity follows by counting outgoing edges from .
Past exam of the mathematics course of the University of Cambridge 2002 iii Paper 9 2 Solution Created 2026-10-03 Updated 2026-10-14
Each vertex of a bipartite graph has a strict preference ordering of its neighbours; every neighbour is preferred to being unmatched. A stable matching in a bipartite graph is a matching in a graph with no blocking edge: an unused edge blocks if both endpoints prefer each other to their assigned partners, interpreting an unmatched endpoint as willing to accept any neighbour. Stability does not require a perfect matching in a graph.
For existence, run the Gale-Shapley algorithm. Whenever a vertex in the first part is unmatched and has an untried neighbour, it proposes to its most preferred untried neighbour. A receiver keeps its preferred proposal and rejects the other, including any previously held proposal. At most proposals occur, so the procedure stops with a matching in a graph. Suppose an edge blocked this final matching in a graph. Since prefers to its final partner, or is unmatched, must have proposed to . But a receiver's held proposal only improves, so 's final partner is preferred to if was rejected. If was not rejected, the edge is in the matching in a graph. Both alternatives contradict blocking. Every finite bipartite preference instance therefore has a stable matching.
For the mutual-worst edge in stable matchings, let be stable matchings with and . We give the argument using alternating graph components including possible unmatched endpoints. If were unmatched in , then would have to prefer its -partner to , since otherwise would block . Following the -edge from , stability of forces its other endpoint to have and prefer an -partner. Stability of then forces the next vertex to have and prefer an -partner. These implications continue along the alternating graph component of . They cannot stop, because at a missing next edge the preceding edge would block the appropriate matching in a graph. They also cannot close into a cycle in a graph, since the graph component already has endpoint . This contradiction proves that is matched in . The same reasoning applies to .
Now prefers its -partner to , because is its worst choice. Along the alternating graph component, stability of forces that partner to prefer its -partner; stability of forces the next vertex in 's part to prefer its -partner, and so on. A graph path graph component is impossible by the same endpoint argument, so this is a cycle in a graph. Thus throughout this cycle in a graph the part containing prefers and the part containing prefers . In particular must prefer to its -partner. That contradicts being 's worst choice. Hence an edge ranked last by both endpoints, if present in one stable matching, is present in every stable matching.
For the list edge coloring assertion, let be the maximum degree. We first prove that the chromatic index is . Use induction on the number of edges, with a proper -edge coloring of . Some color is missing at and some color is missing at . If , color with it. Otherwise the edges of colors form alternating graph paths and even cycles in a graph. The graph component containing cannot contain : an alternating graph path from , starting with color , would end at with color , have even length, and place in the same bipartition class. Swap in the graph component containing . Now is missing at both ends of , so it can be colored . The lower bound is immediate at a vertex of vertex degree .
Fix such a proper coloring . Orient the line graph toward the smaller color at vertices in the first part of , and toward the larger color at vertices in the second part. A vertex of the line graph corresponding to an edge of color has outdegree at mostEvery induced subgraph of this orientation has a digraph kernel. Indeed, restrict to its edge set in the original bipartite graph, give first-part vertices a preference for smaller colors and second-part vertices a preference for larger colors, and choose a stable matching. Its edges form an independent set in the line graph. Every edge outside the matching in a graph has an endpoint whose partner is preferred to it, by stability; thus it has an outgoing edge to the independent set. This proves that the orientation is a kernel-perfect directed graph.
Here is the kernel list-coloring lemma with its proof. If a kernel-perfect directed graph has lists satisfying , choose any color appearing in a list and a digraph kernel of the induced subgraph on vertices whose lists contain . Color with , delete , and delete from the remaining lists. Each remaining vertex that loses a color had an outgoing neighbour in , so its outdegree decreases by at least one; the list inequality persists. Vertices not losing a color also retain the inequality. Induction on the number of vertices completes a proper list coloring.
Lists of size satisfy that lemma for our oriented line graph, so . Identical lists show . Consequently the Galvin theorem for bipartite list edge coloring givesThe empty graph is immediate; if parallel edges are allowed, orient their line-graph adjacency in both directions when the two endpoints prescribe opposite directions. The outdegree bound still holds, and the same stable matching and digraph kernel proof applies with preferences on incident edges.
Regular tournament 2026-10-14
For a finite source alphabet with at least two symbols and strictly positive weights, every ternary prefix code minimizing weighted codeword length has all internal vertices of outdegree three, except possibly one of outdegree two whose tree children are deepest tree leaves.
To prove this, let be the greatest tree leaf depth. A missing tree child at any depth would permit moving a deepest tree leaf into that vacant branch, strictly reducing its positive weighted cost. Thus all internal vertices above depth have three tree children. Tree parents at depth have only tree leaves as tree children; one tree child would permit contraction and strict improvement. If two such tree parents each had two tree children, move one tree child of the second into the first tree parent's third slot, preserving its depth, and contract the second tree parent's remaining tree child. This again strictly improves cost. There is therefore at most one binary tree parent. If the number of symbols is an odd number, the leaf-count formula for a full ternary tree forces to be an even integer; since , there is no binary tree parent.
Strict positivity matters. For probabilities , the prefix code minimizes expected codeword length at one trit, yet has unary vertices and a deepest tree leaf without a sibling codeword. Removing or rearranging zero-weight branches can select a reduced minimizer, but arbitrary minimizers need not have the positive-weight shape.