GTOIgraph theory, redesigned

Index

Problems

180 problems cited across the book, each with the reason it was chosen. Difficulty labels follow the page that sets them: warm-up is a first read, core is the technique of the page, hard needs one more idea.

1Graphs and Models18chapter pages

CSES 1666Building Roadswarm-upcomponents↳ A Zoo of GraphsCF 977ECyclic Componentscorecycles↳ A Zoo of GraphsSPOJ PT07YIs it a tree?warm-uptrees↳ A Zoo of GraphsCSES 1192Counting Roomswarm-upgrid, components↳ Four Ways to Store a GraphCSES 1666Building Roadswarm-upcomponents + DSU↳ Four Ways to Store a GraphSPOJ PT07YIs it a tree?warm-upm = n-1 + connectivity↳ Four Ways to Store a GraphCF 1385EDirecting Edgescoreorientation, DAG↳ Walks, Trails, Paths, CyclesCF 915DAlmost Acyclic Graphhardis one vertex on every directed cycle? test all n candidates↳ Walks, Trails, Paths, CyclesCF 1354EGraph Coloringhardbipartite sides per component, then a DP over them to hit the class sizes↳ Subgraphs, Minors and OperationsCF 566FClique in the Divisibility Graphcorean induced clique is a divisibility chain↳ Subgraphs, Minors and OperationsCSES 2076Necessary Roadscorebridges↳ Connectivity, Bridges, Articulation PointsCSES 1685New Flight Routeshardbridges, orientation↳ Connectivity, Bridges, Articulation PointsCF 1000EWe Need More Bosseshardbridge tree, diameter↳ Connectivity, Bridges, Articulation PointsCSES 1666Building Roadswarm-upcomponents↳ Connectivity, Bridges, Articulation PointsCSES 1668Building Teamswarm-up2-colouring↳ Bipartite Graphs and 2-ColouringSPOJ BUGLIFEBuggy… lovewarm-up2-colouring↳ Bipartite Graphs and 2-ColouringCF 1338BEdge Weight Assignmenthardparity of paths between leaves, one DFS↳ Bipartite Graphs and 2-ColouringCSES 2179Even Outdegree Edgeshardparity, matching↳ Bipartite Graphs and 2-Colouring

2Trees24chapter pages

SPOJ PT07ZLongest path in a treewarm-updiameter↳ Trees: Six Definitions of One ObjectCF 519EA and B and Lecture Roomscoresubtree sizes and LCA↳ Trees: Six Definitions of One ObjectCSES 1674Subordinateswarm-upsubtree sizes, counted bottom-up↳ Trees: Six Definitions of One ObjectCSES 1132Tree Distances Icorererooting↳ Distance, Radius, EccentricityCSES 1133Tree Distances IIcoresum of distances↳ Distance, Radius, EccentricityCF 700BConnecting Universitieshardedge contribution↳ Distance, Radius, EccentricityCSES 1134Prüfer Codecoredecoding↳ Counting Trees: Cayley and PrüferCF 9DHow many trees?hardDP, Catalan-ish↳ Counting Trees: Cayley and PrüferSPOJ HIGHWAYSCounting Highwayshardmatrix-tree theorem↳ Counting Trees: Cayley and PrüferCSES 1669Round Tripcoreundirected cycle↳ Depth-First SearchCF 977ECyclic ComponentscoreDFS classification↳ Depth-First SearchCSES 1679Course SchedulecoreDFS + cycle↳ Depth-First SearchCF 459EPashmak and Graphhardedge orientation↳ Depth-First SearchCSES 1193Labyrinthwarm-upgrid BFS↳ Breadth-First SearchCSES 1194Monsterscoremulti-source BFS↳ Breadth-First SearchCF 1242B0-1 MSTcoredense graph, so traverse the complement↳ Breadth-First SearchCSES 1670Swap Gamecoreimplicit graph BFS↳ Breadth-First SearchCSES 1131Tree Diameterwarm-uptwo BFS↳ Tree Diameter in Two PassesSPOJ PT07ZLongest path in a treewarm-uptwo BFS↳ Tree Diameter in Two PassesCF 1000EWe Need More Bosseshardbridges + diameter↳ Tree Diameter in Two PassesCSES 2079Finding a Centroidcoresubtree sizes↳ Tree Diameter in Two PassesCSES 1137Subtree Queriescoretin/tout + segtree↳ Entry/Exit Times and the Euler TourCSES 1674Subordinateswarm-upsubtree sizes↳ Entry/Exit Times and the Euler TourCF 339DXenia and Bit Operationscoretree-as-segtree↳ Entry/Exit Times and the Euler Tour

3Directed Graphs22chapter pages

CSES 1682Flight Routes Checkcorestrong connectivity↳ Orientations, In/Out-Degree, Strong vs WeakCF 1385EDirecting Edgescoreorientation + toposort↳ Orientations, In/Out-Degree, Strong vs WeakCSES 2179Even Outdegree Edgeshardorientation, matching↳ Orientations, In/Out-Degree, Strong vs WeakCSES 1679Course Schedulewarm-upKahn↳ DAGs and Topological OrderCSES 1681Game RoutescoreDAG counting↳ DAGs and Topological OrderCSES 1680Longest Flight RoutecoreDAG DP↳ DAGs and Topological OrderCF 1385EDirecting Edgescoremixed graph↳ DAGs and Topological OrderCSES 1683Planets and Kingdomscoreoutput components↳ Strongly Connected ComponentsCF 427CCheckpostscoremin cost per SCC↳ Strongly Connected ComponentsCSES 1705Forbidden CitieshardSCC + reachability↳ Strongly Connected ComponentsCSES 1682Flight Routes Checkcoreone SCC, or exhibit a pair that breaks it↳ Strongly Connected ComponentsCSES 1678Round Trip IIcoredirected cycle output↳ Cycles: Detection, Extraction, Feedback SetsCSES 1757Course Schedule IIcoreprint the cycle↳ Cycles: Detection, Extraction, Feedback SetsCF 977ECyclic Componentscorewhich components are pure cycles↳ Cycles: Detection, Extraction, Feedback SetsCSES 2138Reachable NodeshardDAG reachability, bitsets↳ Cycles: Detection, Extraction, Feedback SetsCSES 1750Planets Queries Icorebinary lifting↳ Functional and Permutation GraphsCSES 1751Planets Cyclescorepeel + cycle id↳ Functional and Permutation GraphsCF 25DRoads not only in Berlandwarm-upDSU on a functional model↳ Functional and Permutation GraphsCSES 1730Nim Game Iwarm-upxor↳ Games on Directed GraphsCSES 1729Stick GamecoreSprague-Grundy↳ Games on Directed GraphsCSES 2207Grundy's Gamehardmex, splitting games↳ Games on Directed GraphsCSES 1099Stair Gamehardinvariant↳ Games on Directed Graphs

4Proof Toolkit4chapter pages

5Euler Tours and Hamilton Cycles11chapter pages

6Shortest Paths13chapter pages

7Matrices7chapter pages

8Data Structures on Trees17chapter pages

9Hardness and Escape Routes4chapter pages

10Lowest Common Ancestor8chapter pages

11Advanced Tree Algorithms16chapter pages

CSES 1666Building Roadswarm-upthe unweighted case: MST weight = components - 1↳ Minimum Spanning TreeCF 160DEdges in MSTcoreclassify every edge: in some / every / no MST↳ Minimum Spanning TreeCF 600ELomsat gelralcorethe standard small-to-large statement↳ Small-to-Large MergingCSES 1137Subtree Querieswarm-upthe flattening alternative — compare the two approaches on the same data↳ Small-to-Large MergingCSES 2079Finding a Centroidwarm-upthe single-level version↳ Centroid DecompositionCF 342EXenia and Treehardthe dynamic nearest-marked pattern, O(log2 n) per operation↳ Centroid DecompositionCSES 1133Tree Distances IIcorecentroid is overkill here — know why rerooting wins↳ Centroid DecompositionSPOJ QTREEQuery on a treehardmax edge on a path with updates — the benchmark for HLD↳ Heavy-Light DecompositionCSES 1135Distance Queriescoresolve with HLD's lca to compare code size against lifting↳ Heavy-Light DecompositionCSES 1137Subtree Querieswarm-upthe interval half of the same machinery↳ Heavy-Light DecompositionCSES 1700Tree Isomorphism Icorerooted, canonical hash↳ Tree Hashing and IsomorphismCSES 1701Tree Isomorphism IIhardunrooted — center-based reduction↳ Tree Hashing and IsomorphismCSES 1674Subordinateswarm-upthe subtree-shape information hashing builds on↳ Tree Hashing and IsomorphismCSES 1631Reading Bookswarm-upthe "max vs half" edge case where Huffman-style merging degenerates↳ Huffman CodingCSES 1073Towerswarm-upthe same "extract an extreme from a heap" skeleton, different greedy↳ Huffman CodingCF 9DHow many trees?hardcounting the trees Huffman builds: DP over (nodes, depth) instead of merging them↳ Huffman Coding

12Cuts and Flows10chapter pages

13Matching14chapter pages

CSES 1696School Dancecorethe bipartite matching statement with output pairs↳ Matching: Definitions and DualityCSES 1130Tree Matchingwarm-upmaximum matching on a tree is DP, not flow — know both↳ Matching: Definitions and DualityCSES 1696School Dancecoreoutput the pairs, not just the size↳ Bipartite Matching (Kuhn's Algorithm)CSES 1130Tree Matchingwarm-upthe same objective on a tree, where DP beats augmenting paths↳ Bipartite Matching (Kuhn's Algorithm)CSES 1130Tree Matchingwarm-upsame objective, and HK is the wrong tool — see why↳ Hopcroft–KarpCSES 1696School DancecoreHK and Kuhn on the same input; time both if you can↳ Hopcroft–KarpCSES 1696School Dancecoreextend it: also print a minimum set of students+parents that "touches" every acceptable pair↳ Kőnig's Theorem and Minimum CoversCSES 1130Tree Matchingwarm-upon a tree the cover dual is the same DP with a second state — derive it and check it matches the matching size↳ Kőnig's Theorem and Minimum CoversCSES 2121Parcel Deliveryhardflow-with-costs — the case where MCMF is the right tool and Hungarian is not↳ The Hungarian AlgorithmCSES 1631Reading Bookswarm-upa "pairing" instance with no matching needed — a good calibration of when not to reach for the algorithm↳ The Hungarian AlgorithmCSES 1696School Dancecoremaximum matching with explicit output — the base of every reduction above↳ Matching ApplicationsCSES 2181Counting Tilingshardthe counting version: DP, not matching — the contrast is the lesson↳ Matching ApplicationsCSES 1696School Dancewarm-upre-solve it with a general-graph matching routine and compare the code length↳ General Matching and BlossomsCSES 1130Tree Matchingcorea graph where blossoms can never appear: prove the DP is enough because there are no odd cycles↳ General Matching and Blossoms

14Special Topics12chapter pages

CSES 1666Building Roadswarm-upthe word "roads" is not a planarity hypothesis — a calibration exercise in reading↳ Planarity and Euler's FormulaCSES 1752Creating Officesharddominating-set style; planar-greedy intuitions fail here, and it is worth seeing why↳ Planarity and Euler's FormulaCSES 1134Prüfer Codewarm-upthe tree case: degree of v = occurrences of v + 1, exactly why ∑ di = 2n-2↳ Degree Sequences and Graphical SequencesCSES 2138Reachable Nodescoredegree-sequence intuition versus actual reachability — a useful reality check↳ Degree Sequences and Graphical SequencesCSES 1668Building Teamswarm-upthe 2-colouring case, in public↳ Graph ColouringCSES 1684Giant Pizzacore2-SAT, i.e. "2-colouring with clauses" — see 2-SAT↳ Graph ColouringCSES 1684Giant Pizzacorethe textbook 2-SAT instance: two toppings per pizza, contradictory preferences↳ 2-SATCSES 1682Flight Routes Checkwarm-upthe SCC machinery you need, without the SAT part↳ 2-SATCSES 1751Planets Cyclescorefunctional-graph walk length until repetition — the deterministic twin↳ Random Walks and Cover TimesCSES 1750Planets Queries Iwarm-up"where is the walk after k steps": lifting, not expectations↳ Random Walks and Cover TimesCSES 1130Tree Matchingwarm-upthe two-state DP in its simplest form (the dual of independent set on a tree)↳ Independent Sets, Cliques, and TreewidthCSES 1696School Dancecorethe bipartite route to α = n - ν: solve it with matching and compare with the DP↳ Independent Sets, Cliques, and Treewidth