- Learn
- Mathematics
- University Math
- Discrete Mathematics
- Graphs and Trees
Graphs and Trees
IntermediateLesson 10 of 10 in Discrete Mathematics Course
What you will learn
- Turn networks and relationships into graphs, use the basic vocabulary precisely, count degrees and edges with the handshaking theorem, and recognize the standard families of graphs.
- Model a situation as a graphDecide what the vertices and edges stand for, and choose between simple graphs, multigraphs, pseudographs, directed graphs and weighted graphs.
- Count degrees and use the handshaking theoremFind degrees, in-degrees and out-degrees, use the handshaking theorem to count edges or prove that a graph cannot exist, and test degree sequences.
- Recognize special graphs and build new graphs from old onesUse complete graphs, cycles, paths, wheels, hypercubes and complete bipartite graphs with their vertex and edge counts, and form subgraphs, complements and unions.
- Model a situation as a graph
- Store graphs as adjacency lists, adjacency matrices and incidence matrices, and decide whether two graphs are isomorphic by building a bijection or finding an invariant that differs.
- Store a graph as an adjacency list or a matrixWrite and read adjacency lists, adjacency matrices and incidence matrices for undirected and directed graphs, and choose a suitable representation.
- Decide whether two graphs are isomorphicUse the definition of graph isomorphism, prove that graphs are not isomorphic with invariants, and prove that they are isomorphic with an explicit bijection.
- Store a graph as an adjacency list or a matrix
- Describe how vertices are linked by walks and paths, find the weak points of a network, and decide when a route through every edge (Euler) or every vertex (Hamilton) exists.
- Follow walks and paths and test connectivityDistinguish walks, trails, paths, circuits and cycles, find components and distances, test connectivity of undirected and directed graphs, and count walks with powers of the adjacency matrix.
- Find cut vertices, bridges and the connectivity of a networkIdentify the vertices and edges whose failure splits a graph, explain why bridges are the edges on no cycle, and compare vertex connectivity, edge connectivity and minimum degree.
- Decide when an Euler circuit or trail exists and find oneState and justify the degree conditions for Euler circuits and Euler trails, construct them by hand, and apply them to route problems.
- Reason about Hamilton paths and cyclesDecide by argument whether small graphs have Hamilton paths or cycles, apply Dirac's and Ore's sufficient conditions, and connect Hamilton cycles to Gray codes and the traveling salesperson problem.
- Follow walks and paths and test connectivity
- Recognize bipartite graphs and test for them, and pair up the two sides of a bipartite graph with matchings, using Hall's theorem and augmenting paths.
- Recognize and test bipartite graphsUse the definition and the odd-cycle characterization of bipartite graphs, and test a graph by two-coloring it.
- Find matchings and apply Hall's theoremDistinguish maximal, maximum, perfect and complete matchings, use Hall's condition to decide whether one side can be fully matched, and enlarge a matching along an augmenting path.
- Recognize and test bipartite graphs
- Decide whether a graph can be drawn without crossings using Euler's formula and Kuratowski's theorem, and find chromatic numbers for scheduling and map coloring.
- Use Euler's formula for planar graphsDraw graphs without crossings, count faces, apply Euler's formula and derive the edge bounds for simple planar graphs.
- Prove that a graph is not planarShow nonplanarity with edge-count inequalities and with Kuratowski's theorem, and know which tests are necessary conditions only.
- Color graphs and find the chromatic numberFind proper colorings and chromatic numbers with matching upper and lower bounds, use greedy coloring, and apply coloring to scheduling and maps, including the four color theorem.
- Use Euler's formula for planar graphs
- Prove and use the equivalent characterizations of trees, describe rooted and m-ary trees, and find, count and minimize spanning trees of connected graphs.
- Recognize trees and use their propertiesUse the equivalent definitions of a tree, prove that a tree with n vertices has n − 1 edges, and count leaves, edges and components of trees and forests.
- Describe rooted trees and m-ary treesUse the vocabulary of rooted trees, apply the counting formulas for full m-ary trees, and relate the height of a tree to its number of leaves.
- Find and count spanning treesExplain why a graph has a spanning tree exactly when it is connected, build spanning trees by removing cycle edges or by depth-first and breadth-first search by hand, and count the spanning trees of small graphs.
- Build minimum spanning trees with Kruskal's and Prim's algorithmsFind a spanning tree of least total weight by hand with Kruskal's and Prim's algorithms, and explain why their greedy choices are correct.
- Recognize trees and use their properties
Graphs and Trees study guide
1Model situations with graphs and count degrees
A network becomes easier to analyze when its objects and connections are stated precisely. You will choose the right graph model, count connections at vertices, and use those counts to check whether a proposed graph can exist. Familiar families such as cycles, complete graphs, and hypercubes then provide reusable structures. Their counts also give practice in double counting before you work with more complex networks.
1.1 Vertices, edges, and graph models
A graph keeps the relationships that matter in a situation. Its vertices represent objects, and its edges represent connections. Before drawing anything, state what one vertex means and exactly when an edge exists.
Choose the kind of connection
Write a graph as . The finite, nonempty set holds the vertices, and holds the edges. An edge's ends are its endpoints. Two vertices joined by an edge are adjacent, or neighbors; the edge is incident with each endpoint. A vertex with no incident edges is isolated and still belongs to the graph.
| Graph model | Connections it records |
|---|---|
| Simple undirected graph | At most one edge between distinct vertices; no loops |
| Multigraph | Several edges may join the same two vertices |
| Pseudograph | Parallel edges and loops are allowed |
| Directed graph | Each edge has a start and an end |
| Weighted graph | Each edge carries a numerical value |
An undirected edge expresses a symmetric connection. A directed edge expresses a connection from to ; reversing it changes the edge. For example, “follows” gives a directed social network because one person may follow another without being followed back. A digraph without parallel edges represents a relation on its vertex set.
Weights add a measured amount, such as travel time in minutes or distance in kilometers. They can be used with directed or undirected edges. Two towns can be adjacent even when the edge between them has a large weight: adjacency records the existence of a link, not its size.
Build a model from a question
Suppose a club contains Ana, Ben, Chen, Dara, and Eli. The friendships are Ana–Ben, Ana–Chen, Ben–Chen, Chen–Dara, and Dara–Eli. Use one vertex per person and one edge per friendship. Friendship is mutual, and the model only records whether it exists, so this is a simple undirected graph with 5 vertices and 5 edges.
Eli's only neighbor is Dara. Dara also has Chen as a neighbor, so Dara can introduce Eli to Chen. The social question has become a question about neighbors. If another club member has no friends in the club, add an isolated vertex for that person; leaving the person out changes the network's connectivity.
For roads, first decide whether each road is one-way. If two separate bridges between the same banks must each be crossed, give them separate edges in a multigraph. If the problem asks for total cable length, attach lengths as weights. A model's choices follow what must be counted or compared.
Read the connections, not the artwork
Moving a vertex or bending an edge leaves a graph unchanged. A crossing of two lines is not a vertex unless it is marked as one. Draw as a square with both diagonals, or as a triangle with a fourth vertex inside joined to all three corners. Both pictures have the same six pairs of adjacent vertices. Only the second is a drawing without crossings.
Key Takeaways
- Choose vertices and an exact edge rule before drawing the graph.
- Direction records one-way relationships; weights record amounts.
- Parallel edges and loops require a model that allows them.
- Isolated vertices count; unmarked crossings do not.
1.2 Degree sums and possible degree sequences
Counting connections at vertices gives a quick check on an entire graph. The key is to count edge ends consistently, including both ends of a loop.
Count each edge end
The degree counts the edges incident with , with a loop contributing 2. In a simple graph it equals the number of neighbors. Degree 0 means isolated; degree 1 means pendant. Write the smallest degree as and the largest as .
Handshaking theorem: .
Every edge has two ends. Counting ends vertex by vertex gives the degree sum, while counting them edge by edge gives twice the number of edges. This proves the formula even when loops and parallel edges are present.
In the club graph with edges Ana–Ben, Ana–Chen, Ben–Chen, Chen–Dara, and Dara–Eli, the degrees are 2, 2, 3, 2, and 1. Their sum is 10, so there are edges. A 4-regular graph on 10 vertices similarly has edges. In general a -regular graph on vertices has edges.
The degree sum is even. After removing all even terms from that sum, the odd terms must still add to an even number. Thus the number of odd-degree vertices is even. Seven people cannot each shake hands with exactly three others: that would require an odd sum of 21.
Test more than parity
A degree sequence lists degrees in decreasing order. It is graphic when a simple graph realizes it. Each entry must lie between 0 and , and the sum must be even. These checks alone are insufficient: has an even sum, but three vertices adjacent to every other vertex force the fourth to have degree 3 as well.
Use the Havel–Hakimi test for a complete decision:
- Delete the largest entry .
- Subtract 1 from the next largest entries.
- Sort the remaining sequence and repeat.
Reaching all zeros means graphic. A negative entry, or too few entries to subtract from, means not graphic. The reduction preserves whether a simple graph exists: it accounts for the neighbors of the vertex just removed.
For example,
The sequence is graphic. In contrast, fails. Sort after every reduction; subtracting from arbitrary small entries can reject a valid sequence.
Directed degrees and repeated values
In a digraph, in-degree counts incoming arrows and out-degree counts outgoing arrows. A loop contributes 1 to each. Every arrow has one start and one end, so each total equals , not . Out-degrees 2, 1, 3, 0 give 6 arrows and a total in-degree of 6.
There is also a useful pigeonhole argument: among vertices in a simple graph, two have equal degrees. Degrees range from 0 through , but 0 and cannot both occur. A vertex adjacent to everyone rules out an isolated vertex, leaving at most degree values for vertices.
Key Takeaways
- The undirected degree sum is twice the edge count; a loop contributes 2.
- The number of odd-degree vertices is even.
- An even degree sum is necessary but insufficient for a sequence to be graphic.
- Havel–Hakimi removes the largest entry, reduces the next entries, and sorts again.
- Total in-degree and total out-degree each equal the directed edge count.
- A simple graph with at least two vertices has two equal degrees.
1.3 Graph families and graph operations
Standard graph families give you structures whose counts can be found without listing every edge. Pay attention to what the subscript counts: it does not mean the same thing for every family.
Count the familiar families
| Graph | Vertices | Edges | Degrees |
|---|---|---|---|
| Complete graph | All | ||
| Cycle , | All 2 | ||
| Path graph | Ends 1, inner vertices 2 when | ||
| Wheel , | Hub , rim 3 | ||
| Hypercube , | All | ||
| Complete bipartite | on one side, on the other |
In , every unordered pair is an edge. There are pairs. A round-robin competition with six teams therefore needs 15 games. A cycle closes a row of vertices into a ring; a path leaves the ends unjoined. The one-vertex path has no edges.
The wheel adds a hub to the -vertex rim and joins it to every rim vertex. There are rim edges and spokes, so has 6 vertices and 10 edges. This indexing convention counts rim vertices, not total vertices. For the hub and rim degrees differ, while is 3-regular. A graph is regular when all vertices have the same degree.
Read bit strings and two-part graphs
The vertices of are all bit strings of length . Two are adjacent exactly when one bit differs. Each vertex has possible bit changes, so its degree is . The handshaking theorem gives edges. The cube has 8 vertices and 12 edges; 010 is adjacent to 110, 000, and 011.
In , edges join every vertex of one part to every vertex of the other, with none inside a part. Choose one endpoint in ways and the other in ways to get edges. Using would incorrectly include within-part pairs.
Keep, delete, and complement
A subgraph keeps some vertices and some of the original edges between them. Deleting a vertex also deletes all its incident edges. Deleting an edge keeps its endpoints. An induced subgraph keeps every original edge whose endpoints both lie in ; a spanning subgraph keeps every vertex.
For a triangle with a pendant edge attached at , the induced subgraph on must contain all three triangle edges. The subgraph with only and on those vertices is valid but not induced.
The complement keeps the vertices of a simple graph and reverses adjacency between distinct vertices. Its edge count is . The complement of has 5 edges and is another 5-cycle, drawn in a different order. The union of two graphs takes the union of their vertex sets and edge sets; an edge appearing in both is included once.
Key Takeaways
- Use the family’s construction to derive its vertex, edge, and degree counts.
- Here Pₙ counts vertices and Wₙ counts rim vertices.
- A hypercube joins bit strings that differ in exactly one position.
- An induced subgraph keeps every available edge among its chosen vertices.
- The complement reverses adjacency between distinct vertices.
2Represent graphs and recognize when two graphs are the same
A graph can be stored without a picture, and the same graph can have many pictures or matrices. Adjacency lists and matrices preserve connections in different forms, each suited to different tasks. You will read those forms, keep their ordering conventions straight, and then compare whole graphs. Isomorphism proofs use explicit vertex matches, while invariants provide quick ways to rule matches out.
2.1 Adjacency lists and graph matrices
A list or matrix records a graph without relying on a picture. Fix the vertex labels and, for a matrix, their order. Otherwise a row or column has no clear meaning.
Store neighbors in a list
Take the graph with vertices and edges . Its adjacency list is:
Each undirected edge appears twice, once at each endpoint. Include a row for every vertex, even an empty row for an isolated vertex. In a digraph, list the terminal vertices of outgoing arrows; an incoming arrow alone does not put a vertex in that outgoing list.
Store pairs in an adjacency matrix
With vertex order , the same graph has
The entry records how many edges run from row vertex to column vertex . For a simple undirected graph the matrix is symmetric, has only zeros and ones, and has zero diagonal. Its row sums are degrees: 2, 2, 3, 1 here. The total is 8, twice the four edges.
Parallel edges give entries greater than 1. Count a loop once on the diagonal in this unit. A loop then contributes 1 to a row sum but 2 to the undirected degree. For example, one loop at and one edge give row sum 2 at but degree 3. If a matrix instead counts loops twice, halve its diagonal entries before drawing loops or counting walks by powers.
For a directed matrix, counts arrows from to . Row sums are out-degrees and column sums are in-degrees. Symmetry is unnecessary. A directed loop contributes 1 to each of those sums.
Store endpoints in an incidence matrix
An incidence matrix has vertices as rows and edges as columns. Its entry is 1 when the vertex is an endpoint of that edge, and 0 otherwise. For the same graph, ordering the columns as gives
Each column has two ones and each row sum is a degree because this graph has no loops. Parallel edges would give separate identical columns, preserving their separate identities.
Choose and read a representation
An adjacency matrix always has entries. A list uses about storage for vertices and edges. With 1,000 vertices of degree 3, the graph has 1,500 edges and the lists have 3,000 neighbor entries; the matrix has 1,000,000 entries. Lists are compact for sparse graphs. Matrices make adjacency a single lookup and support algebraic operations.
To reconstruct an undirected graph, read entries above the diagonal once, then add the diagonal loops. Reading both halves as separate edges would double the graph's edges. For a digraph, read every entry as a directed count. Reordering vertices permutes rows and columns together: different matrices can represent the same graph.
Key Takeaways
- An adjacency list records neighbors; a directed list records outgoing neighbors.
- An adjacency matrix needs a fixed vertex order.
- For simple undirected graphs, the matrix is symmetric and row sums are degrees.
- Here each loop counts once on the adjacency diagonal.
- Incidence matrices use vertices as rows and edges as columns.
- Relabeling a matrix requires the same permutation of rows and columns.
2.2 Proving that graphs have the same structure
Two graph drawings may look different because their vertices have been moved or renamed. An isomorphism makes “the same structure” precise by matching vertices while preserving all adjacency.
State what the matching must do
An isomorphism from to is a bijection such that
A bijection maps every vertex to one distinct vertex and reaches every target vertex. The double implication requires edges to go to edges and non-edges to non-edges. This is stronger than finding a copy of one graph inside another. Mapping a three-vertex path into a triangle preserves its two edges but introduces an extra adjacency between its ends.
In directed graphs, preserve the direction too: must correspond to . Matching an arrow in the opposite direction fails even if its endpoints have been correctly paired.
Rule out impossible matches
An invariant is a property preserved by isomorphism. Compare the vertex and edge counts first, then degree sequences, components, triangle counts, and other short cycles. You can also compare the degrees of the neighbors of a particular vertex, whether it lies on a triangle, or whether it is adjacent to a pendant vertex.
One difference settles nonisomorphism. The cycle and two separate triangles both have six vertices, six edges, and degree sequence . Yet one is connected and the other has two components. Their triangle counts also differ. Equal degree sequences leave important structure undecided.
| Evidence | What it establishes |
|---|---|
| One invariant differs | The graphs are not isomorphic |
| Several checked invariants agree | These checks have not distinguished the graphs |
| A bijection preserves adjacency in both directions | The graphs are isomorphic |
Build and verify a bijection
Let have edges 12, 23, 34, 41, 13. Let have edges . Both degree sequences are . In the degree-3 vertices are 1 and 3; in they are and . Try
The five edges of map to , all in . The maps are distinct because is a bijection. Both graphs have five edges, so these images exhaust all edges of and also guarantee that non-edges stay non-edges. Without equal edge counts, an edge-only check would be incomplete.
When a first attempt fails, use local structure to restrict another attempt. A degree-1 vertex must map to degree 1, and its neighbor must map to a vertex of the same degree as that neighbor. Such restrictions are far quicker than blindly testing all bijections.
For a useful less obvious example, the complement of is also a 5-cycle: its edges can be followed in the order 1–3–5–2–4–1. Map successive vertices of the original cycle to that order. The complement changes which labeled pairs are edges, yet the unlabeled structure remains the same.
Key Takeaways
- An isomorphism is a bijection preserving both adjacency and nonadjacency.
- One differing invariant proves nonisomorphism; matching degree sequences alone are insufficient.
- Use vertex degrees and neighbor structure to narrow possible maps.
- With equal edge counts, checking every edge under a bijection also settles non-edges.
3Analyze connectivity, paths and circuits
Routes through a network answer several different questions: whether a destination is reachable, which failures split the network, whether every edge can be used once, and whether every vertex can be visited once. You will separate these demands and learn the evidence each needs. Degree parity settles Euler routes after connectivity is checked; Hamilton cycles require structural arguments or sufficient conditions.
3.1 Walks, paths, and reachable vertices
A route through a graph is a sequence of adjacent vertices, together with the edges used. Different route names tell you what may repeat. Those distinctions matter when a matrix counts routes or a problem asks for a path.
Name the route precisely
| Route | Repetition allowed |
|---|---|
| Walk | Vertices and edges may repeat |
| Trail | No edge repeats |
| Path | No vertex repeats |
| Circuit | A closed trail |
| Cycle | A closed walk of length at least 3 with only the start/end repeated |
The length is the number of edges used, including repetitions. A walk is closed when its first and last vertices agree. With edges , the route has length 3 but repeats , so it is not a trail. The route is a path; is a cycle. Rosen uses “path” for a walk and “simple path” for a trail; the definitions in this table fix the meaning used here.
Every walk between distinct vertices contains a path between them. If a vertex repeats, remove the section between its two appearances. The remaining sequence is still a walk with the same ends. Continuing this deletion leaves no repeated vertices. Thus reachability can be tested with paths even when a route was first found as a walk.
Find components and distance
A graph is connected when a path joins every pair of vertices. A component is a maximal connected subgraph: add any other vertex and it is no longer connected. An isolated vertex forms its own component.
Being joined by a path is an equivalence relation. A length-0 path gives reflexivity; reversal gives symmetry; joining routes and removing repetitions gives transitivity. Its equivalence classes are exactly the components.
The distance is the length of a shortest path. In the example, through . Edge weights are not used in this unweighted distance. In a digraph, strong connectivity requires directed paths in both directions for every pair. Weak connectivity only requires connection after arrow directions are ignored. The arrows give weak connectivity, but no route leads from back to .
Count walks with matrix powers
For adjacency matrix , counting loops once on the diagonal,
counts walks of exactly length from to .
The matrix product explains why. Every length- walk first reaches some vertex in steps, then uses an edge to . Summing over counts all such choices. This is precisely the row-by-column rule.
In the running graph, there is one length-2 walk from to : . There are three length-3 walks from to : ; ; . Two repeat an edge, so these entries are not path counts.
A path in an -vertex graph uses at most edges. Therefore connectivity is equivalent to all off-diagonal entries of being positive. One zero entry of a single power only rules out that exact length; it may still be possible to reach the vertex in fewer or more steps.
In a simple graph, the diagonal sum of is six times its triangle count. A closed three-edge walk must go around a triangle; each triangle supplies three starting vertices and two directions. Thus a diagonal sum of 6 records one triangle. Loops would introduce other closed three-step walks, so this shortcut uses the simple-graph condition.
Key Takeaways
- A trail repeats no edge; a path repeats no vertex.
- Components partition the vertex set by reachability.
- Strong connectivity respects arrows in both directions; weak connectivity ignores directions.
- Distance counts edges in a shortest path.
- Adjacency-matrix powers count walks of an exact length, including repetitions.
3.2 Bridges, cut vertices, and network resilience
A connected network can depend on one link or one central location. To identify that dependence, remove the proposed point of failure and compare the number of components before and after.
Separate vertex failure from edge failure
A cut vertex, or articulation point, is a vertex whose deletion increases the number of components. Deleting it removes all its incident edges too. A bridge, or cut edge, is an edge whose deletion increases the number of components while retaining both endpoints.
Consider two triangles and sharing only . Removing leaves the separate edges and . Thus is a cut vertex. No edge is a bridge: removing one triangle edge still leaves its endpoints connected along the other two sides.
This example separates the two failures. A network can survive every single edge failure while still depending on one vertex. Conversely, looking only for high-degree vertices misses vulnerabilities: an inner vertex of a path has degree 2 and is a cut vertex. The high-degree hub of a wheel is not a cut vertex, because its deletion leaves the connected rim.
Use cycles to identify bridges
An edge is a bridge exactly when it lies on no cycle.
If lies on a cycle, the rest of that cycle gives another route from to after its deletion. Any route that used the deleted edge can use that detour, so connectivity is preserved.
In the other direction, suppose deleting leaves a path from to . That path together with forms a cycle. An edge on no cycle therefore has no replacement route and must be a bridge. Every edge of a tree is a bridge because a tree has no cycles.
For a hand check, mark all vertices reachable from one vertex after the deletion. A newly unreachable group certifies a split. For a candidate bridge, looking for a cycle through the edge is often quicker than repeating the full reachability check.
Measure how many failures are needed
The vertex connectivity is the fewest vertices whose deletion disconnects the graph or leaves a single vertex. In particular, , and disconnected graphs have vertex connectivity 0. A graph is -connected when . A connected graph on at least three vertices with no cut vertex is 2-connected.
The edge connectivity is the fewest edges whose deletion disconnects a connected graph; use 0 for an already disconnected graph. For simple graphs with at least two vertices, Whitney's inequality states
The right inequality follows by isolating a minimum-degree vertex: delete its incident edges. The inequality is a bound, so identifying one such cut gives an upper bound; a smaller cut may exist.
The two-triangle graph has , , and . No single edge disconnects it, but deleting both edges at isolates , proving . Adding redundant links to a network can remove bridges; ensuring survival of any single router failure additionally requires no cut vertex.
Key Takeaways
- A cut vertex is tested by deleting the vertex and its incident edges.
- A bridge lies on no cycle.
- Vertex and edge resilience can differ.
- For simple graphs, κ(G) ≤ λ(G) ≤ δ(G).
3.3 Using every edge exactly once
An Euler route uses every edge exactly once. It can revisit vertices, so a junction may be passed several times. This is the right model when every street, bridge, or drawn segment must be covered.
Test connectivity and degrees
An Euler circuit finishes where it starts. An Euler trail uses every edge once and may have different endpoints. Ignore isolated vertices when checking whether all edges lie in one component.
| Undirected graph with all edges in one component | Euler route |
|---|---|
| Every degree even | Euler circuit |
| Exactly two odd degrees | Open Euler trail, from one odd vertex to the other |
| More than two odd degrees | No Euler trail |
Each visit to an intermediate vertex uses one incoming edge and one outgoing edge. These edges pair up. In a circuit the initial departure pairs with the final arrival, so every degree is even. In an open trail only the two endpoints have unpaired uses and hence odd degrees. The handshaking theorem rules out exactly one odd-degree vertex.
Connectivity is a separate requirement. Two disjoint triangles have even degrees everywhere, but no single route can cover both. The Königsberg bridge graph has degrees 5, 3, 3, 3: its four odd vertices rule out both an Euler circuit and an open Euler trail.
Construct a circuit by splicing
Hierholzer's method explains why even degrees are sufficient. Start at a vertex with edges and follow unused edges until stuck. At any other vertex, an arrival leaves an unused departure available because the original degree was even. The trail therefore closes at its start.
If unused edges remain, connectivity provides a vertex on the current circuit touching unused edges. Trace another closed trail from it, then splice the new trail into the old one. Repeat until no edge remains unused.
For the triangles and sharing :
- Trace .
- At , trace the unused triangle .
- Insert it at to obtain .
The result uses all six edges exactly once. Vertex appears twice before the final return to , which is permitted. For an open trail, temporarily add an edge between the two odd vertices, build a circuit, then remove the added edge and start just after it.
Fleury's rule is another hand method: avoid a bridge of the still-unused graph unless no other edge is available. Check bridges in the remaining graph, not just the original graph, because earlier steps change the available detours.
Respect arrows in a directed route
For a directed graph, all edges must belong to one weakly connected component. A directed Euler circuit exists exactly when in-degree equals out-degree at every vertex. For an open trail from to , must have one extra outgoing edge, one extra incoming edge, and every other vertex must be balanced.
In a square with diagonal , only and have odd degree. The trail uses all five edges and ends at the other odd vertex. This is an edge-covering task: visiting every vertex once would ask a different question.
Key Takeaways
- Euler routes use every edge once and may repeat vertices.
- All edges must lie in one component.
- Even degrees give a circuit; exactly two odd degrees give an open trail.
- Hierholzer builds closed trails and splices them at shared vertices.
- Fleury tests bridges among the edges still unused.
- Directed Euler routes require the matching in-degree and out-degree balances.
3.4 Visiting every vertex exactly once
A Hamilton route visits every vertex exactly once. A Hamilton cycle returns to its starting vertex at the end. Extra edges may remain unused, so counting odd degrees does not settle a Hamilton question.
Distinguish the two route problems
| Route | Must use | May repeat |
|---|---|---|
| Euler trail or circuit | Every edge once | Vertices |
| Hamilton path or cycle | Every vertex once, with the start repeated at the end of a cycle | No other vertices |
A Hamiltonian graph has a Hamilton cycle. A leaf rules out such a cycle because a cycle needs two incident edges at each visited vertex. A cut vertex also rules it out: deleting one vertex from a Hamilton cycle leaves a path through every remaining vertex, so the remaining graph must stay connected.
More generally, deleting vertices from a Hamiltonian graph leaves at most components. The deleted vertices break the cycle into at most pieces. A graph that splits into more pieces fails this necessary condition.
For a small graph, degree-2 vertices can force choices. Both their incident edges must be on a Hamilton cycle. If those forced choices demand three cycle edges at some vertex, or close a smaller cycle before all vertices are included, no Hamilton cycle exists.
Apply sufficient degree conditions
For a simple graph on vertices:
- Dirac's theorem: minimum degree at least guarantees a Hamilton cycle.
- Ore's theorem: degree sum at least for every nonadjacent pair guarantees a Hamilton cycle.
Dirac implies Ore because each of the two degrees is at least . For , all eight vertices have degree 4, so Dirac applies.
These are sufficient tests. A failed test leaves the outcome open. For example, has degree 2 everywhere, below , but its rim is already a Hamilton cycle. In a general graph no efficient algorithm deciding every Hamilton-cycle instance is known; the decision problem is NP-complete.
Use bipartite structure
Every step in a bipartite graph switches parts. A cycle therefore uses equal numbers of vertices from each part. Thus has no Hamilton cycle, but it has the path . A Hamilton path's two part sizes can differ by one because its start and end may be in the larger part.
The Petersen graph has 10 vertices, degree 3 everywhere, and no cut vertex, yet it has no Hamilton cycle. It does have a Hamilton path. Equal degrees and the absence of obvious cut vertices are not enough for a cycle.
Count tours and encode bit changes
In with , fix the starting vertex and arrange the other vertices. Reverse directions describe the same undirected cycle, giving Hamilton cycles. For this is 12. The traveling salesperson problem adds edge weights and asks for the least-weight Hamilton cycle.
A Hamilton cycle of gives a cyclic Gray code, listing all length- bit strings so that consecutive strings, including the last and first, differ in one bit. Such cycles exist for . For three bits, one order is 000, 001, 011, 010, 110, 111, 101, 100; the closing step also changes one bit.
Key Takeaways
- Hamilton paths visit every vertex once; cycles also close at the start.
- Dirac and Ore guarantee cycles when their degree conditions hold.
- Failure of a sufficient condition leaves Hamiltonicity undecided.
- Leaves, forced edges, separating vertex sets, and unequal bipartite parts can obstruct cycles.
- Kₙ has (n − 1)!/2 undirected Hamilton cycles for n ≥ 3.
- A cyclic Gray code is a Hamilton cycle of a hypercube.
4Work with bipartite graphs and matchings
Pairing two groups begins with the connections that are allowed between them. A two-coloring reveals whether a graph has the required bipartite structure, while an odd cycle explains a failure. You will then choose disjoint edges to match vertices, test whether enough partners exist for every group, and reroute a partial matching when it can be enlarged. Individual choices and shared constraints both matter.
4.1 Two-coloring and odd cycles
A bipartite graph splits its vertices into two parts so that every edge crosses between them. The parts describe a structural property; the vertices do not have to be drawn in two columns.
Build the two parts
Write the parts as and . They are disjoint and together contain every vertex. No edge has both endpoints in one part. Equivalently, assign two colors so every edge joins unlike colors.
Complete bipartite graphs have this property by construction. A cycle is bipartite when is even: alternate colors around the ring. If is odd, the last vertex gets the same color as its adjacent start, causing a conflict. Thus the absence of triangles alone is insufficient; a 5-cycle also prevents a two-coloring.
A graph is bipartite if and only if it has no odd cycle.
For one direction, each edge of a cycle switches parts. Returning to the starting part takes an even number of switches. For the converse, choose a root in a connected component and separate vertices by even or odd distance from it. An edge joining equal-parity levels would create an odd closed walk, from which an odd cycle can be extracted. With no odd cycles, every edge crosses the distance-parity split.
Test a graph by hand
Start at any vertex, color it A, and color its neighbors B. Work outward, assigning each uncolored neighbor the opposite color. Inspect edges to vertices already colored too. Such edges can expose a conflict even when no new vertex is discovered. Restart at an uncolored vertex if another component remains.
For edges 12, 23, 34, 45, 56, 61, and 14:
- Color vertex 1 A.
- Color its neighbors 2, 4, 6 B.
- Color 3 and 5 A.
- Check every edge; each joins the two colors.
The parts are and . Adding 13 creates a conflict and the odd cycle 1–2–3–1. The edge exposes a concrete obstruction, not merely a failure of one drawing.
Each component can swap its colors independently. Thus disconnected graphs may have several different valid partitions. Isolated vertices can go in either part because they impose no edge restrictions.
Recognize hidden bipartite structure
Every tree is bipartite: color by the parity of distance from any root. The hypercube is bipartite too. Put strings with an even number of ones in one part and strings with an odd number in the other; changing one bit switches that parity.
If the parts have sizes and , there are only possible cross-part pairs, so there are at most edges in a simple bipartite graph. With , this product is largest for parts as equal as possible, giving at most edges. On 10 vertices the maximum is 25, attained by .
Deleting edges or vertices preserves bipartiteness, because the same two-coloring still works on what remains. Applicants joined to jobs they qualify for naturally give a bipartite model; the next question is whether distinct applicants can be paired with distinct jobs.
Key Takeaways
- Bipartite means every edge crosses a partition into two parts.
- A graph is bipartite exactly when it has no odd cycle.
- Test every component by assigning opposite colors across every edge.
- Trees and hypercubes are bipartite.
- A simple bipartite graph on n vertices has at most ⌊n²/4⌋ edges.
4.2 Matchings, Hall’s condition, and augmenting paths
A matching chooses connections without reusing endpoints. In an applicant–job graph, it assigns at most one job to each applicant and at most one applicant to each job. The aim is often to cover a whole side.
Distinguish the goals of a matching
| Term | Meaning |
|---|---|
| Matching | A set of edges with no shared endpoints |
| Maximal matching | No further edge can be added while keeping all chosen edges |
| Maximum matching | Has the greatest possible number of edges |
| Perfect matching | Covers every vertex |
| Complete matching from to | Covers every vertex of |
A maximum matching is maximal, but a maximal one can be too small. In the path , the matching blocks both other edges and is maximal. Replacing it with gives two edges and is perfect.
A perfect matching requires an even total number of vertices. For a bipartite graph it requires equally sized parts, since every matching edge uses one vertex from each part. Equal sizes alone do not guarantee that suitable edges exist.
Check groups, not just individuals
For , let be all vertices adjacent to at least one member of . Hall's marriage theorem states that a complete matching from exists exactly when
The necessity follows from distinct assignments: the members of need distinct partners within . The sufficiency direction can be proved by strong induction on the number of vertices in .
Suppose Ana can do J1 or J2, Bo and Cy can each do only J1, and Dee can do J2, J3, or J4. The set has only one neighbor, J1. Hall fails because , even though every applicant has at least one possible job. Ana–J2, Bo–J1, Dee–J3 gives three matches; the deficient pair rules out four, so three is maximum.
For existence, an explicit complete matching is a short certificate: there is no need to inspect every subset once such an assignment is displayed. For nonexistence, one deficient subset is enough.
Enlarge a matching by rerouting
An alternating path switches between edges outside and inside the current matching. An augmenting path has unmatched endpoints. It starts and ends with unmatched edges, so flipping the status of every edge along it increases the matching size by one.
The path augments : remove and add . Internal vertices lose one matched edge and gain one; the two endpoints become newly matched. Berge's theorem says a matching is maximum exactly when no augmenting path exists.
Hall also proves that every -regular bipartite graph with has a perfect matching. Degree sums first show the two parts have equal size. For a subset , its incident edges end in , which can receive at most such edges. Thus Hall holds. In , perfect matchings are bijections between the parts, so there are of them.
Key Takeaways
- Maximal means no direct addition; maximum means largest possible.
- Perfect covers both sides; a complete matching from one side covers that side.
- Hall tests every subset of the side to be covered.
- One deficient subset proves nonexistence; an explicit assignment proves existence.
- Flipping an augmenting path increases matching size by one.
- A positive-regular bipartite graph has a perfect matching.
5Draw planar graphs and color graphs
Crossings and conflicts ask different questions about the same connections. A planar drawing avoids crossings, and counting its faces gives restrictions on how many edges it can contain. A coloring assigns different choices to adjacent vertices. You will use certificates for planarity or nonplanarity, then combine lower bounds with actual colorings to establish the fewest time slots or colors needed.
5.1 Faces and Euler’s formula
Planarity asks whether a graph has any drawing without edge crossings. Once such a drawing is available, counting its regions reveals a strong relationship between vertices and edges.
Count every face
A graph is planar if it has a drawing in the plane where edges meet only at shared endpoints. Such a drawing is a plane drawing or embedding. The regions are its faces, including the unbounded outer face.
The degree of a face counts edge sides around its boundary. A bridge touches the same face on both sides and is counted twice. Every edge has two sides, so the sum of all face degrees is . A tree has just the outer face, whose boundary counts every edge twice.
For a connected plane graph with vertices, edges, and faces,
Euler's formula: .
The cube has . In a plane drawing of there are three bounded triangular faces and the outer face, giving . Counting only bounded regions would make the formula fail by one.
If the graph has components, use . For two disjoint triangles, , , and : the two interiors plus the shared outer face. Each component does not get its own separate outer face in the whole drawing.
Understand why the formula holds
A connected acyclic graph is a tree, with and one face. It therefore satisfies Euler's formula. If a connected plane graph has a cycle, remove an edge of that cycle. The remaining graph stays connected and two faces merge. Both and fall by one, so stays unchanged. Repeating reaches a tree and proves the formula for the original graph.
This argument also explains why a bridge behaves differently: removing it disconnects the graph instead of merging two different faces.
Bound the number of edges
For a simple connected plane graph with , each face boundary has degree at least 3. Consequently . Substitute :
If the graph is also triangle-free, each face has degree at least 4, giving and . Bipartite graphs have no triangles, so the stronger bound applies to them. The restrictions matter: parallel edges can bound a two-sided face, and a triangle-free hypothesis cannot be used just because a drawing hides its triangles.
Combine degree and face counts
Suppose a connected planar graph has 20 vertices, all degree 3. First use handshaking to find . Then Euler gives . The face count comes after the edge count; degree sums do not count faces directly.
Every simple planar graph has a vertex of degree at most 5. If every degree were at least 6, then would contradict for a component of at least three vertices. Components of one or two vertices already have small-degree vertices. This low-degree fact supports inductive coloring arguments.
Key Takeaways
- Planarity means some drawing avoids crossings.
- Count the outer face; a bridge contributes twice to its face boundary.
- Connected plane graphs satisfy v − e + f = 2.
- With c components, v − e + f = 1 + c.
- Simple planar graphs with v ≥ 3 satisfy e ≤ 3v − 6; triangle-free ones satisfy e ≤ 2v − 4.
5.2 Certifying nonplanarity
A crowded drawing can often be rearranged. To establish nonplanarity, give an obstruction that survives every redrawing: too many edges, or a forbidden subdivided structure.
Choose the right inequality
A simple connected planar graph with satisfies . The complete graph has 5 vertices and 10 edges, while the bound allows only 9. This contradiction proves that no plane drawing exists.
For a triangle-free graph, use . The bipartite graph has 6 vertices and 9 edges, exceeding the allowed 8. This explains why the three-utilities puzzle cannot be drawn on a flat plane with all nine connections and no crossings.
A passed inequality leaves the question open. Indeed satisfies the weaker bound and is still nonplanar. A bound is a necessary condition for planarity, not a construction of an embedding.
For a connected planar graph containing a cycle with girth , the shortest cycle length, a sharper bound is
The Petersen graph has , , and girth 5. The right side is , ruling out planarity. The hypercube instead fails the triangle-free bound: its 16 vertices and 32 edges exceed .
Follow subdivided edges
An elementary subdivision replaces an edge by two edges through a new vertex. Repeating subdivisions stretches edges into paths. This preserves planarity: put each new vertex along its old edge. Conversely, suppressing the inserted degree-2 vertices recovers the old drawing.
Two graphs are homeomorphic when both arise by subdividing a common graph. A subdivided may have many more than five vertices, but it still carries five branch vertices and a path for each original connection.
Kuratowski's theorem: a graph is planar exactly when it contains no subgraph that is a subdivision of or .
For a obstruction, select five branch vertices and ten connecting paths, one for each pair. For a obstruction, select two groups of three branch vertices and nine paths across the groups. The paths must have disjoint interiors; a branch vertex cannot sit inside another connecting path. Paths sharing an internal vertex do not establish the required subdivision.
Use an obstruction inside a larger graph
The forbidden subdivision need only be a subgraph. Extra edges can be ignored, because a plane drawing of the whole graph would also draw every subgraph without crossings. A subdivision of needs branch vertices of degree at least 4. In a 3-regular graph such as the Petersen graph, a Kuratowski search must therefore look for the kind.
Both and are minimal nonplanar: deleting any one of their edges makes the graph planar. Subdividing them instead preserves nonplanarity. This distinction is useful when a sparse graph passes an edge bound but still contains a stretched forbidden pattern.
Key Takeaways
- Violating a planar edge bound proves nonplanarity.
- Passing a necessary edge bound leaves planarity open.
- Subdividing an edge preserves planarity or nonplanarity.
- Kuratowski obstructions are subdivisions of K₅ or K₃,₃ inside a subgraph.
- The connecting paths in the obstruction must have disjoint interiors.
5.3 Coloring conflicts with as few colors as possible
A coloring models choices that must differ at connected pairs. Exams that share students, for example, need different time slots. Color every vertex so that every edge has differently colored endpoints.
Prove both bounds
A proper coloring assigns colors to vertices with no equal-colored adjacent pair. A graph is -colorable when at most colors suffice. Its chromatic number is the smallest number that works.
A displayed coloring proves an upper bound. To prove equality, also show why fewer colors fail. A clique of size gives the lower bound , since all its vertices are pairwise adjacent. An odd cycle can establish a lower bound of 3 even when there is no triangle.
| Graph | Chromatic number |
|---|---|
| Nonempty vertex set with no edges | 1 |
| Even cycle | 2 |
| Odd cycle | 3 |
| Wheel with even rim length | 3 |
| Wheel with odd rim length | 4 |
The wheel's hub is adjacent to every rim vertex, so it needs a color absent from the entire rim. The rim needs two or three colors according to parity; then add one for the hub. The clique number gives , but equality need not hold: has largest clique size 2 and chromatic number 3.
Try greedy coloring
Choose a vertex order. Give each vertex the lowest-numbered color not used by its already colored neighbors. At most colors are blocked, so greedy coloring uses at most colors.
The result depends on order. In the path , the order assigns colors 1, 1, 2, 3. The order uses only 1, 2, 1, 2. Thus a greedy result is a valid upper bound, but it may exceed the chromatic number.
Translate a schedule into a proof
Join exams M, P, C, B, H, E when some student takes both. Suppose the edges are MP, MC, PC, CB, BH, HE, EB. Triangle MPC forces at least three time slots. Assign M and B slot 1, P and H slot 2, and C and E slot 3. Every conflict edge crosses slots, including CB. Three slots work and fewer fail, so the minimum is exactly three.
The same model assigns different radio frequencies to nearby transmitters or different registers to simultaneously needed variables. The edge rule must express an actual conflict; objects can share a color when no edge joins them.
Apply planar coloring results
For a map with connected regions, make one vertex per region and join regions sharing a border segment. Meeting only at a point does not create adjacency. The resulting graph is planar. The four color theorem states that every planar graph can be properly colored with at most four colors. Some need fewer; shows four can be necessary.
The low-degree fact gives an easier six-color proof: remove a vertex of degree at most 5, color the rest by induction, then return the vertex. At most five colors are blocked, leaving a sixth. The five color theorem gives a stronger bound; the four color theorem was first proved with computer assistance. These planar bounds do not apply to arbitrary graphs such as .
Key Takeaways
- A proper coloring separates every adjacent pair.
- Prove χ = k with a k-coloring and a lower bound of k.
- Cliques give lower bounds; greedy coloring gives an upper bound of Δ + 1.
- A greedy coloring can use more colors than necessary.
- Wheel coloring needs the rim colors plus a new hub color.
- Every planar graph is at most four-colorable.
6Characterize trees and build spanning trees
A tree has a route between every pair of vertices and no redundant cycle. Its equivalent descriptions connect unique paths, leaves, and edge counts. Choosing a root adds levels and branching formulas. You will then extract trees that span a larger graph and compare their total weights, using Kruskal and Prim to choose inexpensive links while retaining the mathematical reason each choice is safe.
6.1 Trees, leaves, and equivalent tests
A tree connects all its vertices without a cycle. It has enough edges to connect everything, but no spare edge. This makes trees a useful way to describe networks with no redundant links.
Connect the characterizations
For an undirected graph with vertices, each of these statements characterizes a tree:
- It is connected and acyclic.
- Exactly one path joins every pair of vertices.
- It is connected and has edges.
- It is acyclic and has edges.
- It is connected and every edge deletion disconnects it.
- It is acyclic and every new edge creates exactly one cycle.
Unique paths follow from connectedness and acyclicity. Connectedness provides at least one path. If two distinct paths joined the same pair, their first divergence and later reunion would contain a cycle. Conversely, a cycle gives two paths between two of its vertices.
Every tree edge is a bridge: another path between its endpoints would make a cycle. Adding a missing edge closes the unique existing path between its endpoints into one cycle. These facts explain the names minimally connected and maximally acyclic.
Remove a leaf to prove the edge formula
A leaf has degree 1. Every tree with at least two vertices has at least two leaves. Take a longest path. An endpoint cannot have a neighbor outside the path, because the path could be extended, and cannot have another neighbor on the path, because that would create a cycle. Both endpoints therefore have degree 1.
Now use induction to prove the edge count. A one-vertex tree has zero edges. For a tree on vertices, remove a leaf and its one edge. The remaining graph is still connected and acyclic. By induction it has edges. Returning the leaf gives edges.
A forest is acyclic and may be disconnected. Each component is a tree. If its components contain vertices, their edge counts add to .
Use enough evidence
The count alone is insufficient. A triangle plus an isolated vertex has four vertices and three edges, but has a cycle and is disconnected. Combine the count with connectedness or with acyclicity. Similarly, connected graphs may have cycles, and forests may have several components.
Suppose a tree has two degree-4 vertices, one degree-3 vertex, and otherwise only leaves. If is the number of leaves, then . Handshaking gives
so . There are ten vertices and nine edges. The equation uses the tree edge count as well as the stated degrees.
Recognize trees in other settings
A tree is bipartite: color its vertices by even or odd distance from any chosen root. Its unique paths prevent conflicting colors. Different shapes may have identical counts; the numbers of nonisomorphic trees on 1 through 7 vertices are 1, 1, 1, 2, 3, 6, 11. On four vertices the two shapes are the path and the star.
In an alkane model, carbon atoms have degree 4 and hydrogen atoms degree 1. A connected molecule with formula has atoms and single bonds, so its atom-and-bond graph is a tree. The two carbon skeletons of butane correspond to the four-vertex path and star shapes; attaching hydrogens gives the full fourteen-vertex molecular graphs.
Key Takeaways
- A tree is connected and acyclic, equivalently it has unique paths.
- A tree on n vertices has n − 1 edges.
- Every tree with at least two vertices has at least two leaves.
- A forest with n vertices and c components has n − c edges.
- Every tree edge is a bridge, and adding a new edge creates one cycle.
- The edge count n − 1 needs connectedness or acyclicity to identify a tree.
6.2 Rooted trees and branching counts
Choosing a root gives a tree a direction from one starting vertex outward. It turns its unique paths into parent–child relationships and makes height a precise count of edges.
Describe positions from the root
Every nonroot vertex has one parent, its predecessor on the path from the root. Its successors are its children. Children of the same parent are siblings. The other vertices on the path to the root are ancestors; vertices below it along these paths are descendants. The subtree at a vertex consists of it and all its descendants.
A vertex with children is internal. A rooted leaf has no children. This definition includes a root-only tree, even though its root has undirected degree 0. In a larger rooted tree, the root can have undirected degree 1 and still be internal because it has a child.
The level, or depth, counts edges from the root. The root has level 0. Height is the largest level. A four-vertex path rooted at an end has height 3; rooting it at an inner vertex changes its height to 2. An ordered rooted tree additionally fixes the left-to-right order of each vertex's children.
Count a full m-ary tree
An -ary tree allows at most children at an internal vertex. A full -ary tree requires exactly at each internal vertex. Binary means ; full binary is stronger than binary.
With internal vertices, the full tree has parent-to-child edges. Every vertex except the root is exactly one child, so
Thus . For , you can also use . A full ternary tree with four internal vertices has 13 vertices and nine leaves. If the derived count is not an integer, the proposed full tree cannot exist.
A single-elimination tournament with 64 entrants has one leaf per entrant and one internal vertex per match. With two entrants feeding each match, the tree is full binary. It has matches. These are total matches, not rounds; the number of rounds concerns height.
Relate height to leaves
For , an -ary tree of height has at most leaves. Each level can branch at most ways. Hence
For 1,000 leaves in a binary tree, , so height is at least 10. This lower bound does not force every tree with that leaf count to have height 10; an uneven tree can be taller.
Here balanced means all leaves occur at levels or . A full balanced -ary tree attains . Full alone does not mean balanced: one branch can continue while others stop.
For a comparison decision tree sorting four distinct items, leaves represent all possible orders. Each comparison has two outcomes, so the tree is binary. Since , at least five comparisons are required in the worst case. The bound concerns the longest root-to-leaf path, not the total number of comparisons written across the entire tree.
Key Takeaways
- Depth and height count edges; the root is at level 0.
- A rooted leaf has no children; an internal vertex has children.
- Full m-ary trees have n = mi + 1 and ℓ = (m − 1)i + 1.
- For m ≥ 2, height is at least ⌈logₘ ℓ⌉.
- Full and balanced describe different restrictions.
6.3 Building and counting spanning trees
A spanning tree keeps every vertex of a graph and enough of its original edges to connect them without cycles. It is a simplified network, not a selection of only the easiest vertices to connect.
Remove redundant edges
A graph has a spanning tree exactly when it is connected.
A spanning tree supplies paths between every pair, so its host graph must be connected. Conversely, start with a connected graph. Whenever a cycle remains, delete one of its edges. That edge has a detour around the rest of the cycle, so connectedness survives. The finite process ends with a connected acyclic spanning subgraph: a spanning tree.
Every spanning tree on vertices has edges. Starting with edges therefore requires exactly deletions, regardless of the choices. For , delete three of its six edges while maintaining connectedness.
Having edges alone is insufficient. In a graph containing a triangle and a fourth vertex, choosing the triangle's three edges leaves that fourth vertex isolated. Verify either connectedness or acyclicity along with the count.
Grow a tree from a root
Instead of deleting, add an edge each time you discover a new vertex. One endpoint is in the growing tree and the other has not been visited, so no cycle is created.
- Depth-first search by hand: keep extending the current route to an unvisited neighbor; back up when it has none.
- Breadth-first search by hand: add all unvisited neighbors of the root, then expand the newly reached vertices level by level.
Breadth-first levels equal distances from the root. Its tree path to each vertex is therefore a shortest path in the unweighted graph. A depth-first tree need not have that distance property.
For edges 12, 23, 34, 45, 56, 61, 14, start breadth-first at 1 and consider neighbors in increasing order. First add 12, 14, 16. Expand 2 to add 23, then 4 to add 45. All six vertices are reached with five edges. The two omitted edges, 34 and 56, match deletions.
Exchange edges and count trees
Adding an unused graph edge to a spanning tree closes its unique endpoint path into one cycle. Delete another edge on that cycle to obtain a different spanning tree. This exchange changes the chosen links while keeping all vertices connected.
For , a spanning tree omits exactly one cycle edge. Each of the choices works, giving spanning trees. Cayley's formula gives spanning trees for with : 16 for and 125 for . These count trees on fixed labeled vertices; different labels matter.
For minus one edge, there are three-edge selections. Exactly two are triangles, each leaving the fourth vertex isolated. The other eight are spanning trees. This count requires identifying and excluding the cyclic selections, not assuming all combinations work.
A disconnected graph has no spanning tree. Choose one tree in each component instead to get a spanning forest with edges for components. No edges between the original components are available to join those trees.
Key Takeaways
- A spanning tree exists exactly when the graph is connected.
- Cycle-edge deletion preserves connectivity and removes m − n + 1 edges in total.
- Growing to new vertices builds a spanning tree; breadth-first paths minimize edge count from the root.
- Adding an unused edge and deleting another cycle edge exchanges spanning trees.
- Cₙ has n spanning trees; Kₙ has nⁿ⁻² labeled spanning trees for n ≥ 2.
6.4 Choosing a spanning tree of minimum weight
When edges carry costs or lengths, different spanning trees can have different totals. A minimum spanning tree connects all vertices with the smallest possible sum of edge weights.
Make safe greedy choices
For a minimum spanning tree, or MST, every vertex must be included and exactly edges are chosen. Minimize their total, not the weight of just one link or one route.
| Method | Eligible edge | Shape during construction |
|---|---|---|
| Kruskal | Lightest remaining edge that creates no cycle | A forest, possibly several pieces |
| Prim | Lightest edge from the current tree to an outside vertex | One growing tree |
Kruskal's algorithm sorts all edges by increasing weight. Accept an edge if its endpoints are in different current components; otherwise skip it. Stop at accepted edges. Sharing one endpoint with a chosen edge is allowed: only closing a cycle is forbidden.
Prim's algorithm starts at any vertex. At every step consider all edges crossing from the current tree to the outside, and choose a lightest one. This need not touch the most recently added vertex. Stop when every vertex belongs to the tree.
Work through the same network
Five towns have candidate cable links in kilometers: AB 5, AC 3, BC 4, BD 7, CD 9, CE 8, DE 6, BE 10.
Kruskal processes the edges in this order:
- Accept AC, weight 3.
- Accept BC, weight 4.
- Skip AB, weight 5: A and B are already linked through C.
- Accept DE, weight 6, creating a second piece.
- Accept BD, weight 7, joining the pieces.
Four edges connect the five towns. Their sum is km.
Prim from A accepts AC, then BC. The tree now contains A, B, C, and the lightest outward edge is BD, weight 7. After D joins, DE of weight 6 becomes eligible and is chosen. Prim's accepted weights need not increase: an inexpensive edge can become available later. Both methods give the same tree here.
Explain why the choices work
A cut splits all vertices into two nonempty groups. The cut property says a lightest crossing edge belongs to some MST; if it is uniquely lightest, every MST contains it.
To see why, take an MST omitting the chosen edge and add it. The new cycle crosses the cut again through another edge. Replacing that crossing edge by the chosen one preserves a spanning tree and cannot increase its weight. If the chosen edge is strictly lighter, omitting it would contradict minimality.
During either algorithm, choose a cut crossed by no previously accepted edge. The exchange can then preserve earlier choices. For Prim, use the current tree versus the outside. For Kruskal, use one current component versus the rest.
Distinct edge weights guarantee a unique MST. Ties can allow several trees, all with the same optimal total. Reversing the comparisons gives maximum spanning trees.
An MST need not give shortest routes between towns. In the example its A-to-D route has length km, while the graph offers A–B–D of length km. Minimizing total installed cable and minimizing each journey are different objectives.
Key Takeaways
- An MST minimizes the sum of spanning-tree edge weights.
- Kruskal sorts edges and rejects cycle-closing choices.
- Prim chooses a lightest edge crossing from its tree to an outside vertex.
- The cut property justifies the greedy steps while preserving earlier choices.
- Distinct edge weights guarantee a unique MST; ties can allow several.
- An MST need not provide shortest routes between pairs of vertices.
Graphs and Trees examples
1Build a network and check its counts
12 steps
- 1IntroductionTurn a situation into connections
A graph model begins with two choices: what one vertex represents and exactly when an edge joins two vertices. Once these are clear, degree counts can check the model without relying on its drawing.
We will model candidate links between six sensors, count their endpoints, and then compare the network with standard graph families. Keep the distinction between an object, a connection, and an amount on a connection visible throughout.
- 2ExampleState the sensor model
Six sensors A through F can communicate directly over links AB, AC, BC, CD, DE, DF, EF. One vertex represents one sensor. One undirected edge means that direct communication is possible in both directions.
Each possible link is either present or absent, and no sensor is linked to itself, so a simple graph fits. The network has six vertices and seven edges. The crossing or length of lines in a sketch does not add connections.
- 3ExplanationAdd information only when it matters
Suppose a link takes a stated number of milliseconds to transmit a message. Keep the same graph and place that value on its edge as a weight. If communication works only one way, use an arrow for that direction instead.
If two distinct cables join the same sensors and either cable may fail separately, represent them as parallel edges. Model those separate connections explicitly; a single edge would hide the redundancy being studied.
- 4ChallengeChoose the graph for cable failures
Two routers have three separate cables between them. A failure study must track which cables survive. What graph model keeps the needed information?
---reveal---
Use a multigraph with two vertices and three parallel edges, one per cable. A simple graph would keep only whether the routers are connected and would lose the count of surviving independent cables. A drawing can show the edges as three different curves without introducing extra vertices.
- 5ExampleCount the sensor degrees
Return to the seven sensor links AB, AC, BC, CD, DE, DF, EF. The degrees are A: 2, B: 2, C: 3, D: 3, E: 2, F: 2.
The sum is . Each link appears at both its endpoints. Exactly two vertices, C and D, have odd degree, agreeing with the even-count rule for odd-degree vertices. The degrees measure links, not the transmission-time weights they might carry.
- 6ExampleReduce a proposed sequence
Can a simple graph realize ? Its sum is 16, but evenness is only a first check.
Remove 4 and reduce the next four entries. The remaining entries become ; sorting gives . This first Havel–Hakimi step accounts for all four neighbors of the deleted vertex. It leaves a smaller sequence whose graphic status is the same.
- 7ExampleFinish the sequence test
Continue from . Delete 2 and reduce the next two entries to obtain . Delete 1 and reduce one entry, then sort, giving . One more reduction gives .
All entries have reached zero, so the original sequence is graphic. Sorting after each step matters because the next reduction must use the current largest entries, not their old positions.
- 8ChallengeFind a missing degree
A graph has 11 edges. Five of its six vertex degrees are 4, 4, 3, 3, and 2. What is the last degree?
---reveal---
The total degree is . The five known degrees total 16, so the missing degree is 6. This cannot be a simple graph on six vertices, whose degrees are at most 5; loops or multiple edges would be needed for such degree data. The degree-sum calculation and the simple-graph restriction are separate checks.
- 9ExplanationCount a wheel from its construction
Build from a square rim and one new hub. It has five vertices. The four rim edges and four spokes give eight edges.
The hub has degree 4, and each rim vertex has degree 3. The degree sum checks the edge count. The subscript 4 counts the rim vertices here, not all vertices; reading it as the total would shift both vertex and edge counts.
- 10ConnectionKeep a subgraph or reverse adjacency
In the sensor network, the induced subgraph on C, D, E contains CD and DE, but not CE: that link was absent. An induced subgraph must keep every available link between the chosen vertices.
A complement instead keeps all six vertices and takes exactly the missing pairs. Six vertices have possible pairs, so the seven-edge network has an eight-edge complement. It replaces the edge set instead of merely deleting selected edges.
- 11ChallengeCombine a family count with handshaking
The hypercube has one vertex for each four-bit string. Find its vertex count and edge count.
---reveal---
There are strings. Each has four neighbors, found by changing one of its four bits, so the degree sum is . Divide by two to get 32 edges. Counting 64 edges would count each bit-change connection once from each of its two ends.
- 12RecapMatch the count to the model
When checking a network, first settle whether a link is directed, repeated, or weighted. Then count vertices and edge ends using that model. Degree parity can reject impossible data quickly; a degree-sequence test checks the remaining simple-graph restrictions.
For a standard family, derive counts from its construction. For a subgraph or complement, state which vertices stay and which pairs are retained. This gives a clear basis for later route and connectivity questions.
2Record a graph and verify a vertex renaming
10 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionSeparate representation from structure
- 2ExampleWrite all five neighbor lists
- 3ExplanationRead rows and columns by their labels
- 4ChallengeRead an incidence column
- 5TipCompare before trying every map
- 6ExampleChoose images using local structure
- 7ExampleCheck that every edge survives
- 8ChallengeFind an invariant that settles a mismatch
- 9ChallengeInterpret a simultaneous row and column swap
- 10RecapUse the right certificate
3Analyze routes through a network
16 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionAsk what the route must cover
- 2ExampleTrack repetitions in a route
- 3ExampleCount a two-step walk without drawing
- 4ChallengeFind distance and classify a walk
- 5ExampleRemove a central vertex
- 6Key InsightLocate the edge without a detour
- 7ChallengeRepair one failure without fixing all failures
- 8ExplanationTest Euler parity in the original graph
- 9ExampleBuild the route in pieces
- 10ChallengeUse degree pairing to reject a claim
- 11ConnectionBalance arrows for a directed trail
- 12ExplanationWhy the Euler trail is not a Hamilton cycle
- 13TipApply a theorem without reversing its logic
- 14ChallengeSeparate a path from a cycle in two parts
- 15ChallengeCompare edge coverage and vertex coverage
- 16RecapChoose evidence for the route you need
4Find a valid split and improve an assignment
10 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionFrom allowed pairs to compatible pairs
- 2ExampleBuild a two-coloring from one vertex
- 3ChallengeExpose an odd-cycle conflict
- 4ExplanationChoose pairs without reusing endpoints
- 5Key InsightWhy maximal can still be too small
- 6ExampleTrace the alternating route
- 7ExampleFlip the path
- 8ChallengeFind a Hall obstruction
- 9ChallengeConnect the split to a complete assignment
- 10RecapLocate the reason an assignment stops
5Count faces, find obstructions, and color conflicts
13 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionUse evidence that survives redrawing
- 2ExampleCount the outside region
- 3ExampleAttach a pendant edge
- 4ChallengeHandle a disconnected drawing
- 5ExplanationChoose the stronger applicable bound
- 6ExampleStretch a forbidden graph
- 7ChallengeRead a Kuratowski certificate
- 8ExampleBuild a conflict graph for sessions
- 9ExampleComplete the coloring proof
- 10TipWatch a greedy order use an extra color
- 11ChallengeColor a wheel
- 12ChallengeCombine planar and clique bounds
- 13RecapMatch each claim with its certificate
6Build trees and minimize their total weight
17 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionKeep every vertex with no redundant cycle
- 2ExplanationWhy a tree has unique paths
- 3ExampleRemove a leaf and use induction
- 4ChallengeFind the number of leaves
- 5ExplanationChoose a root and count edges downward
- 6ExampleCount children in a full branching tree
- 7ChallengeUse leaf count to bound height
- 8ExampleExtract a spanning tree by deletion
- 9ConnectionGrow a tree by discovering vertices
- 10ChallengeCount a small set of spanning trees
- 11ExampleList a new weighted network
- 12ExampleTrace Kruskal’s choices
- 13ExampleTrace Prim from a different start
- 14Key InsightUse an exchange to justify a cheap edge
- 15ChallengeUpdate the optimum after a weight change
- 16ChallengeCompare a spanning tree with a tour
- 17RecapCheck structure before optimizing
Graphs and Trees practice questions
Set 1: Paths, failures, and whole-network routes10 Practice Questions
Question 1 of 10
Show answerHide answer
Question 2 of 10
Show answerHide answer
Question 3 of 10
Show answerHide answer
Question 4 of 10
Show answerHide answer
Question 5 of 10
Show answerHide answer
Question 6 of 10
Show answerHide answer
Question 7 of 10
Show answerHide answer
Question 8 of 10
Show answerHide answer
Question 9 of 10
Show answerHide answer
Question 10 of 10
Show answerHide answer
Set 2: Models, degrees, and representations10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 3: Bipartite structure, matching, and planarity10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 4: Trees, branching, and spanning choices10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 5: Combine structure with counting10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 6: Proofs and transfer across graph topics10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Stuck on your own question? Homework Help
Key Terms
A
Adjacency list
Adjacency matrix
Adjacent vertices
Ancestor and descendant
Augmenting path
B
Balanced rooted tree
Bipartite graph
Bipartition
Branch vertex
Breadth-first spanning tree
Bridge
C
Cayley’s formula
Chromatic number
Circuit
Clique number
Complete graph
Connected component
Cut
Cut property
Cut vertex
Cycle
Cycle graph
D
Degree
Degree sequence
Degree-preserving map
Depth-first spanning tree
Dirac’s theorem
Directed graph
E
Edge
Edge connectivity
Euler circuit
Euler trail
Euler’s formula
F
Face
Face degree
Fleury’s rule
Forest
Four color theorem
Full m-ary tree
G
Girth
Graph complement
Graph distance
Graph invariant
Graph isomorphism
Graphic sequence
Gray code
Greedy coloring
H
Hall’s condition
Hamilton cycle
Hamilton path
Handshaking theorem
Havel–Hakimi test
Height
Hierholzer’s method
Hypercube
I
In-degree
Incidence
Incidence matrix
Induced subgraph
Internal vertex
K
Kruskal’s algorithm
Kuratowski’s theorem
L
Leaf
Level
M
Matching
Maximal matching
Maximum matching
Minimum degree
Minimum spanning tree
Multigraph
N
Neighbor set
Nonisomorphic graphs
Nonplanar graph
O
Odd cycle
Ore’s theorem
Out-degree
P
Parent and child
Path
Path graph
Perfect matching
Planar graph
Plane drawing
Prim’s algorithm
Proper vertex coloring
Pseudograph
R
Regular graph
Rooted tree
S
Simple graph
Spanning forest
Spanning tree
Sparse graph
Strong connectivity
Subdivision
T
Trail
Traveling salesperson problem
Tree
Two-coloring
U
Unique-path property
V
Vertex
Vertex connectivity
W
Walk
Weak connectivity
Weighted graph
Wheel graph
About this lesson
Make your own Study Materials
Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.