34 of 40 focal problems use RatMath for a calculation or a substantive step.
Direct calculation
32 · 80%
Assisted
2 · 5%
Worked by hand
6 · 15%
Using the packages
Drawings and exact graph objects complement each other. A returned coloring is an upper bound until a lower bound establishes optimality. Checking one embedding and proving nonplanarity also require different witnesses.
Calculator interface
Keep vertex labels stable while editing the drawing. Highlight a cut, coloring, matching or subdivision on the graph and show the independently checkable witness size.
Each of the 40 focal problems has equal weight. Direct means the displayed package calculation answers the computational question after the inputs are set up. Assisted means it contributes a step and the worked solution supplies essential reasoning, interpretation or selection. Worked by hand means the guide relies on a construction, argument or judgment for that task. The helpful share combines direct and assisted days. Courses and instructors assign different mixes of problems. The percentages describe this syllabus.
Classroom inputs and practical limits
34 of 40 days include a checked executable example. On 9 days the measured size sweep exercises a named API used in the lesson. Each day identifies its tested inputs and the mathematical property checked. Hand-worked days give the input scale and the argument to verify.
Ranges across the five units
Days 1–8 · Graphs and trees. Simple graphs with roughly 3–30 vertices, including trees and sparse graphs. Input size includes edges.
Unit benchmark · discrete.isBipartite, cycle vertices. Largest passing sample 10,000 (21.70 ms, 92.2 MiB peak process RSS). The runs did not locate a ceiling for this family.
Days 9–16 · Walks and cycles. Walk length about 2–10 or Euler/Hamilton examples with a few to tens of vertices; walks may repeat vertices.
Unit benchmark · discrete.spanningTreeCount, complete-graph vertices. Largest passing sample 128 (387 ms, 123.2 MiB peak process RSS). The first sampled passing call above 100 ms used 128 (387 ms). The runs did not locate a ceiling for this family.
Days 17–24 · Planar and topological graphs. Small planar embeddings, named graphs and subdivisions with roughly 4–20 vertices; genus is a different search from planarity.
Unit benchmark · discrete.isBipartite, cycle vertices. Largest passing sample 10,000 (21.70 ms, 92.2 MiB peak process RSS). The runs did not locate a ceiling for this family.
Days 25–32 · Coloring and extremal problems. About 3–15 vertices for hand coloring and exhaustive classroom searches; density and symmetry affect search cost.
Unit benchmark · discrete.chromaticNumber, cycle vertices. Largest passing sample 101 (8.06 ms, 79 MiB peak process RSS). The runs did not locate a ceiling for this family.
Days 33–40 · Graph algorithms and invariants. Matching, flow and invariants on graphs usually with a few to tens of vertices and small integer capacities.
Unit benchmark · discrete.maximumMatching, vertices per side. Largest passing sample 100 (102 ms, 125.5 MiB peak process RSS). The first sampled passing call above 100 ms used 100 (102 ms). The runs did not locate a ceiling for this family.
A graph has degree sequence . How many edges does it have? Build one and check.
Worked solution
, so 6 edges. For example a 5-cycle plus one chord.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
const g = discrete.graph([[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3]]);
console.log([g.size, g.degreeSequence()]);
Checked output
[6, [3, 3, 2, 2, 2]]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Simple graphs with roughly 3–30 vertices, including trees and sparse graphs. Input size includes edges.
For this problem type. Use 3–20 labeled vertices and a stated edge list. For a walk count also supply length, usually a single digit in a hand problem.
Focal example. The code above passed its displayed check in 0.135 ms on Node.
Related workload in this unit.discrete.isBipartite · cycle vertices. Baseline test points across courses 3, 4, 5, 12, 30. A cycle has a bipartition precisely when its length is even.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 10,000 (21.70 ms, 92.2 MiB peak process RSS). The runs did not locate a ceiling for this family. Graph traversal depends on vertices and edges. A long sparse cycle has far fewer edges than a dense graph of the same order.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.252
75.7
4
Baseline
Passed
0.382
74.8
5
Baseline
Passed
0.406
75
12
Baseline
Passed
0.424
74.9
30
Baseline
Passed
0.349
75.7
100
Stretch
Passed
0.609
75.9
1,000
Stretch
Passed
20.72
77.9
10,000
Stretch
Passed
21.70
92.2
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.graph · 10 passing test cases, 21 distinct argument descriptions
Two triangles and are joined by the edge . Find the bridges and cut vertices.
Worked solution
Only lies on no cycle: it is the one bridge. Removing 3 or 4 disconnects the graph: the cut vertices are 3 and 4.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
const g = discrete.graph([[1, 2], [2, 3], [3, 1], [3, 4], [4, 5], [5, 6], [6, 4]]);
console.log([discrete.bridges(g).map((e) => [e.from, e.to]), discrete.cutVertices(g)]);
Checked output
[[[3, 4]], [3, 4]]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Simple graphs with roughly 3–30 vertices, including trees and sparse graphs. Input size includes edges.
For this problem type. Use 3–20 labeled vertices and a stated edge list. For a walk count also supply length, usually a single digit in a hand problem.
Focal example. The code above passed its displayed check in 0.463 ms on Node.
Related workload in this unit.discrete.isBipartite · cycle vertices. Baseline test points across courses 3, 4, 5, 12, 30. A cycle has a bipartition precisely when its length is even.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 10,000 (21.70 ms, 92.2 MiB peak process RSS). The runs did not locate a ceiling for this family. Graph traversal depends on vertices and edges. A long sparse cycle has far fewer edges than a dense graph of the same order.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.252
75.7
4
Baseline
Passed
0.382
74.8
5
Baseline
Passed
0.406
75
12
Baseline
Passed
0.424
74.9
30
Baseline
Passed
0.349
75.7
100
Stretch
Passed
0.609
75.9
1,000
Stretch
Passed
20.72
77.9
10,000
Stretch
Passed
21.70
92.2
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.graph · 10 passing test cases, 21 distinct argument descriptions
Remove the smallest leaf each time and record its neighbour: 1 (4), 2 (4), 3 (4), then 4 is a leaf (5). Code .
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
console.log(discrete.prufer(discrete.graph([[1, 4], [2, 4], [3, 4], [4, 5], [5, 6]])));
Checked output
[4, 4, 4, 5]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Simple graphs with roughly 3–30 vertices, including trees and sparse graphs. Input size includes edges.
For this problem type. Use 3–20 labeled vertices and a stated edge list. For a walk count also supply length, usually a single digit in a hand problem.
Focal example. The code above passed its displayed check in 0.359 ms on Node.
Related workload in this unit.discrete.isBipartite · cycle vertices. Baseline test points across courses 3, 4, 5, 12, 30. A cycle has a bipartition precisely when its length is even.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 10,000 (21.70 ms, 92.2 MiB peak process RSS). The runs did not locate a ceiling for this family. Graph traversal depends on vertices and edges. A long sparse cycle has far fewer edges than a dense graph of the same order.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.252
75.7
4
Baseline
Passed
0.382
74.8
5
Baseline
Passed
0.406
75
12
Baseline
Passed
0.424
74.9
30
Baseline
Passed
0.349
75.7
100
Stretch
Passed
0.609
75.9
1,000
Stretch
Passed
20.72
77.9
10,000
Stretch
Passed
21.70
92.2
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.prufer · 1 passing test case, 1 distinct argument description
Cayley: . A cycle loses any one of its 5 edges: 5.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
console.log(
[discrete.spanningTreeCount(discrete.complete(4)), discrete.spanningTreeCount(discrete.cycleGraph(5))]
);
Checked output
[16n, 5n]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Simple graphs with roughly 3–30 vertices, including trees and sparse graphs. Input size includes edges.
For this problem type. Use 3–20 labeled vertices and a stated edge list. For a walk count also supply length, usually a single digit in a hand problem.
Focal example. The code above passed its displayed check in 0.223 ms on Node.
Same API, measured input family.discrete.spanningTreeCount · complete-graph vertices. Baseline test points across courses 2, 3, 5, 8. Cayley's formula gives n^(n−2) labeled spanning trees of K_n.
Practical limit. Largest passing sample 128 (387 ms, 123.2 MiB peak process RSS). The first sampled passing call above 100 ms used 128 (387 ms). The runs did not locate a ceiling for this family. Each complete graph has n(n−1)/2 edges and a rapidly growing exact tree count. Listing the trees would be much more expensive.
Measured times, memory and outcomes
complete-graph vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
2
Baseline
Passed
0.230
76.4
3
Baseline
Passed
3.52
75.2
5
Baseline
Passed
0.304
75.5
8
Baseline
Passed
0.389
74.7
16
Stretch
Passed
0.809
74.9
32
Stretch
Passed
9.90
77.8
64
Stretch
Passed
23.83
88.7
128
Stretch
Passed
387
123.2
Each row measures the stated fixture. Other inputs to this API can take different paths. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.spanningTreeCount · 2 passing test cases, 1 distinct argument description
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
console.log(discrete.spanningTreeCount(discrete.complete(5)));
Checked output
125n
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Simple graphs with roughly 3–30 vertices, including trees and sparse graphs. Input size includes edges.
For this problem type. Use 3–20 labeled vertices and a stated edge list. For a walk count also supply length, usually a single digit in a hand problem.
Focal example. The code above passed its displayed check in 0.304 ms on Node.
Same API, measured input family.discrete.spanningTreeCount · complete-graph vertices. Baseline test points across courses 2, 3, 5, 8. Cayley's formula gives n^(n−2) labeled spanning trees of K_n.
Practical limit. Largest passing sample 128 (387 ms, 123.2 MiB peak process RSS). The first sampled passing call above 100 ms used 128 (387 ms). The runs did not locate a ceiling for this family. Each complete graph has n(n−1)/2 edges and a rapidly growing exact tree count. Listing the trees would be much more expensive.
Measured times, memory and outcomes
complete-graph vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
2
Baseline
Passed
0.230
76.4
3
Baseline
Passed
3.52
75.2
5
Baseline
Passed
0.304
75.5
8
Baseline
Passed
0.389
74.7
16
Stretch
Passed
0.809
74.9
32
Stretch
Passed
9.90
77.8
64
Stretch
Passed
23.83
88.7
128
Stretch
Passed
387
123.2
Each row measures the stated fixture. Other inputs to this API can take different paths. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.spanningTreeCount · 2 passing test cases, 1 distinct argument description
A connected undirected graph has 12 vertices and 11 edges. Must it be a tree?
Worked solution
Yes. A spanning tree already requires all 11 edges. An additional cycle would allow removal of an edge while keeping the graph connected, which would leave too few edges.
Working without a calculator
Use the argument or construction in the worked solution. This lesson assigns the reasoning to the student.
Input range and limits
Typical inputs for this unit. Simple graphs with roughly 3–30 vertices, including trees and sparse graphs. Input size includes edges.
Scope of verification. This day asks for a hand argument, construction or interpretation. The worked instance gives the input. General claims need the reasoning shown above. A measured time, memory ceiling or finite input sweep would not verify that claim.
Day 07 / 40 · Graphs and trees
Degree parity
Worked by hand
Problem
Can a graph have exactly three vertices of odd degree?
Worked solution
The degree sum is twice the edge count. Any odd sum would contradict that identity.
Working without a calculator
Use the argument or construction in the worked solution. This lesson assigns the reasoning to the student.
Input range and limits
Typical inputs for this unit. Simple graphs with roughly 3–30 vertices, including trees and sparse graphs. Input size includes edges.
Scope of verification. This day asks for a hand argument, construction or interpretation. The worked instance gives the input. General claims need the reasoning shown above. A measured time, memory ceiling or finite input sweep would not verify that claim.
Day 08 / 40 · Graphs and trees
Tree induction
Worked by hand
Problem
Why must a finite tree with at least two vertices have a leaf?
Worked solution
Take a longest simple path. An extra neighbor of its endpoint would either extend the path or create a cycle.
Working without a calculator
Use the argument or construction in the worked solution. This lesson assigns the reasoning to the student.
Input range and limits
Typical inputs for this unit. Simple graphs with roughly 3–30 vertices, including trees and sparse graphs. Input size includes edges.
Scope of verification. This day asks for a hand argument, construction or interpretation. The worked instance gives the input. General claims need the reasoning shown above. A measured time, memory ceiling or finite input sweep would not verify that claim.
Day 09 / 40 · Walks and cycles
Euler tours
Direct calculation@ratmath/discrete
Problem
Does have a closed Euler tour? Does ?
Worked solution
is connected and every degree is 4 (even): yes, a tour of all 10 edges (11 vertices listed). In every degree is 3 (odd): no.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
const a = discrete.eulerTour(discrete.complete(5), { closed: true });
const b = discrete.eulerTour(discrete.complete(4), { closed: true });
console.log([a.exists, a.vertices.length, b.exists]);
Checked output
[true, 11, false]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Walk length about 2–10 or Euler/Hamilton examples with a few to tens of vertices; walks may repeat vertices.
For this problem type. Use 3–20 labeled vertices and a stated edge list. For a walk count also supply length, usually a single digit in a hand problem.
Focal example. The code above passed its displayed check in 0.237 ms on Node.
Related workload in this unit.discrete.isBipartite · cycle vertices. Baseline test points across courses 3, 4, 5, 12, 30. A cycle has a bipartition precisely when its length is even.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 10,000 (21.70 ms, 92.2 MiB peak process RSS). The runs did not locate a ceiling for this family. Graph traversal depends on vertices and edges. A long sparse cycle has far fewer edges than a dense graph of the same order.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.252
75.7
4
Baseline
Passed
0.382
74.8
5
Baseline
Passed
0.406
75
12
Baseline
Passed
0.424
74.9
30
Baseline
Passed
0.349
75.7
100
Stretch
Passed
0.609
75.9
1,000
Stretch
Passed
20.72
77.9
10,000
Stretch
Passed
21.70
92.2
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.eulerTour · 1 passing test case, 3 distinct argument descriptions
Graph, {closed=false} or Graph, {closed=true} · Euler tours
discrete.complete · 14 passing test cases, 9 distinct argument descriptions
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
const h = discrete.hamiltonCycle(discrete.hypercube(3));
console.log([h.exists, h.cycle.length]);
Checked output
[true, 9]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Walk length about 2–10 or Euler/Hamilton examples with a few to tens of vertices; walks may repeat vertices.
For this problem type. Hand graph examples usually have 3–12 vertices. Include edges or graph density as a second input because exact searches of the same order can differ sharply.
Focal example. The code above passed its displayed check in 0.392 ms on Node.
Related workload in this unit.discrete.chromaticNumber · cycle vertices. Baseline test points across courses 3, 4, 5, 10, 15. Odd cycles require three colours, even cycles two.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 101 (8.06 ms, 79 MiB peak process RSS). The runs did not locate a ceiling for this family. Cycles are easy to color. Exact coloring, clique and isomorphism searches can take much longer on less structured graphs of the same size.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.592
74.6
4
Baseline
Passed
0.684
75
5
Baseline
Passed
1.15
74.9
10
Baseline
Passed
0.866
74.7
15
Baseline
Passed
1.74
75.6
25
Stretch
Passed
1.60
75.6
50
Stretch
Passed
1.17
76
101
Stretch
Passed
8.06
79
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.hamiltonCycle · 1 passing test case, 1 distinct argument description
For the Petersen graph give the order, size, girth, diameter, chromatic number, independence number, and whether it is Hamiltonian.
Worked solution
10 vertices, 15 edges, girth 5, diameter 2, , , and it has no Hamilton cycle.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
const P = discrete.petersen();
console.log(
[P.order, P.size, discrete.girth(P).girth, discrete.diameter(P), discrete.chromaticNumber(P).number, discrete.maximumIndependentSet(P).length, discrete.hamiltonCycle(P).exists]
);
Checked output
[10, 15, 5, 2, 3, 4, false]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Walk length about 2–10 or Euler/Hamilton examples with a few to tens of vertices; walks may repeat vertices.
For this problem type. Hand graph examples usually have 3–12 vertices. Include edges or graph density as a second input because exact searches of the same order can differ sharply.
Focal example. The code above passed its displayed check in 2.03 ms on Node.
Same API, measured input family.discrete.chromaticNumber · cycle vertices. Baseline test points across courses 3, 4, 5, 10, 15. Odd cycles require three colours, even cycles two.
Practical limit. Largest passing sample 101 (8.06 ms, 79 MiB peak process RSS). The runs did not locate a ceiling for this family. Cycles are easy to color. Exact coloring, clique and isomorphism searches can take much longer on less structured graphs of the same size.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.592
74.6
4
Baseline
Passed
0.684
75
5
Baseline
Passed
1.15
74.9
10
Baseline
Passed
0.866
74.7
15
Baseline
Passed
1.74
75.6
25
Stretch
Passed
1.60
75.6
50
Stretch
Passed
1.17
76
101
Stretch
Passed
8.06
79
Each row measures the stated fixture. Other inputs to this API can take different paths. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.petersen · 15 passing test cases, 1 distinct argument description
Implementation limit. The default coloring search budget is 2,000,000 steps. Difficulty depends on graph structure. Source at the tested revision
Day 12 / 40 · Walks and cycles
Counting walks
Direct calculation@ratmath/discrete
Problem
How many closed walks of length 3 start and end at a given vertex of ? How many walks of length 3 join two different vertices?
Worked solution
With and : . So (the ordered triangles through ) and .
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
const W = discrete.walks(discrete.complete(4), 3).matrix;
console.log([W[0][0], W[0][1]]);
Checked output
[6n, 7n]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Walk length about 2–10 or Euler/Hamilton examples with a few to tens of vertices; walks may repeat vertices.
For this problem type. Use 3–20 labeled vertices and a stated edge list. For a walk count also supply length, usually a single digit in a hand problem.
Focal example. The code above passed its displayed check in 0.357 ms on Node.
Related workload in this unit.discrete.isBipartite · cycle vertices. Baseline test points across courses 3, 4, 5, 12, 30. A cycle has a bipartition precisely when its length is even.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 10,000 (21.70 ms, 92.2 MiB peak process RSS). The runs did not locate a ceiling for this family. Graph traversal depends on vertices and edges. A long sparse cycle has far fewer edges than a dense graph of the same order.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.252
75.7
4
Baseline
Passed
0.382
74.8
5
Baseline
Passed
0.406
75
12
Baseline
Passed
0.424
74.9
30
Baseline
Passed
0.349
75.7
100
Stretch
Passed
0.609
75.9
1,000
Stretch
Passed
20.72
77.9
10,000
Stretch
Passed
21.70
92.2
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.walks · 1 passing test case, 2 distinct argument descriptions
: every degree is 4 (even) and it is connected, so yes. : degrees are 3, so no.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
console.log(
[discrete.eulerTour(discrete.complete(5)).exists, discrete.eulerTour(discrete.complete(4)).exists]
);
Checked output
[true, false]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Walk length about 2–10 or Euler/Hamilton examples with a few to tens of vertices; walks may repeat vertices.
For this problem type. Use 3–20 labeled vertices and a stated edge list. For a walk count also supply length, usually a single digit in a hand problem.
Focal example. The code above passed its displayed check in 1.19 ms on Node.
Related workload in this unit.discrete.isBipartite · cycle vertices. Baseline test points across courses 3, 4, 5, 12, 30. A cycle has a bipartition precisely when its length is even.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 10,000 (21.70 ms, 92.2 MiB peak process RSS). The runs did not locate a ceiling for this family. Graph traversal depends on vertices and edges. A long sparse cycle has far fewer edges than a dense graph of the same order.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.252
75.7
4
Baseline
Passed
0.382
74.8
5
Baseline
Passed
0.406
75
12
Baseline
Passed
0.424
74.9
30
Baseline
Passed
0.349
75.7
100
Stretch
Passed
0.609
75.9
1,000
Stretch
Passed
20.72
77.9
10,000
Stretch
Passed
21.70
92.2
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.eulerTour · 1 passing test case, 3 distinct argument descriptions
Graph, {closed=false} or Graph, {closed=true} · Euler tours
discrete.complete · 14 passing test cases, 9 distinct argument descriptions
Edges with weights: AB 4, AC 2, BC 1, BD 5, CD 8, CE 10, DE 2. Find the shortest path from A to E.
Worked solution
A–C–B–D–E, length .
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
const g = discrete.graph([["A", "B", 4], ["A", "C", 2], ["B", "C", 1], ["B", "D", 5], ["C", "D", 8], ["C", "E", 10], ["D", "E", 2]]);
const p = discrete.shortestPath(g, "A", "E");
console.log([p.path, p.distance]);
Checked output
[["A", "C", "B", "D", "E"], 10]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Walk length about 2–10 or Euler/Hamilton examples with a few to tens of vertices; walks may repeat vertices.
For this problem type. Use 3–20 labeled vertices and a stated edge list. For a walk count also supply length, usually a single digit in a hand problem.
Focal example. The code above passed its displayed check in 1.06 ms on Node.
Related workload in this unit.discrete.isBipartite · cycle vertices. Baseline test points across courses 3, 4, 5, 12, 30. A cycle has a bipartition precisely when its length is even.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 10,000 (21.70 ms, 92.2 MiB peak process RSS). The runs did not locate a ceiling for this family. Graph traversal depends on vertices and edges. A long sparse cycle has far fewer edges than a dense graph of the same order.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.252
75.7
4
Baseline
Passed
0.382
74.8
5
Baseline
Passed
0.406
75
12
Baseline
Passed
0.424
74.9
30
Baseline
Passed
0.349
75.7
100
Stretch
Passed
0.609
75.9
1,000
Stretch
Passed
20.72
77.9
10,000
Stretch
Passed
21.70
92.2
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.graph · 10 passing test cases, 21 distinct argument descriptions
Can the adjacency-matrix square count walks that revisit their starting vertex?
Worked solution
Yes. Traversing an edge out and back contributes to a diagonal entry. A path with distinct vertices excludes that walk.
Working without a calculator
Use the argument or construction in the worked solution. This lesson assigns the reasoning to the student.
Input range and limits
Typical inputs for this unit. Walk length about 2–10 or Euler/Hamilton examples with a few to tens of vertices; walks may repeat vertices.
Scope of verification. This day asks for a hand argument, construction or interpretation. The worked instance gives the input. General claims need the reasoning shown above. A measured time, memory ceiling or finite input sweep would not verify that claim.
Day 16 / 40 · Walks and cycles
Directed reachability
Direct calculation@ratmath/discrete
Problem
In a directed chain A→B→C, are A and C strongly connected?
Worked solution
A reaches C, but no directed path returns. The underlying undirected chain is connected.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
console.log(discrete.isStronglyConnected(discrete.digraph([["A","B"],["B","C"]])));
Checked output
false
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Walk length about 2–10 or Euler/Hamilton examples with a few to tens of vertices; walks may repeat vertices.
For this problem type. Use 3–20 labeled vertices and a stated edge list. For a walk count also supply length, usually a single digit in a hand problem.
Focal example. The code above passed its displayed check in 0.266 ms on Node.
Related workload in this unit.discrete.isBipartite · cycle vertices. Baseline test points across courses 3, 4, 5, 12, 30. A cycle has a bipartition precisely when its length is even.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 10,000 (21.70 ms, 92.2 MiB peak process RSS). The runs did not locate a ceiling for this family. Graph traversal depends on vertices and edges. A long sparse cycle has far fewer edges than a dense graph of the same order.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.252
75.7
4
Baseline
Passed
0.382
74.8
5
Baseline
Passed
0.406
75
12
Baseline
Passed
0.424
74.9
30
Baseline
Passed
0.349
75.7
100
Stretch
Passed
0.609
75.9
1,000
Stretch
Passed
20.72
77.9
10,000
Stretch
Passed
21.70
92.2
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.digraph · 3 passing test cases, 3 distinct argument descriptions
is planar. has edges, and (triangle-free) has : neither is planar.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
const D = discrete;
console.log(
[D.isPlanar(D.complete(4)), D.isPlanar(D.complete(5)), D.isPlanar(D.completeBipartite(3, 3))]
);
Checked output
[true, false, false]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Small planar embeddings, named graphs and subdivisions with roughly 4–20 vertices; genus is a different search from planarity.
Focal example. The code above passed its displayed check in 2.40 ms on Node.
Related workload in this unit.discrete.isBipartite · cycle vertices. Baseline test points across courses 3, 4, 5, 12, 30. A cycle has a bipartition precisely when its length is even.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 10,000 (21.70 ms, 92.2 MiB peak process RSS). The runs did not locate a ceiling for this family. Graph traversal depends on vertices and edges. A long sparse cycle has far fewer edges than a dense graph of the same order.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.252
75.7
4
Baseline
Passed
0.382
74.8
5
Baseline
Passed
0.406
75
12
Baseline
Passed
0.424
74.9
30
Baseline
Passed
0.349
75.7
100
Stretch
Passed
0.609
75.9
1,000
Stretch
Passed
20.72
77.9
10,000
Stretch
Passed
21.70
92.2
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.isPlanar · 1 passing test case, 1 distinct argument description
Show the Petersen graph is not planar by finding a Kuratowski subgraph.
Worked solution
Use the two-element subsets of {1,2,3,4,5} as Petersen vertices; adjacent labels are disjoint. The nine displayed paths have six branch vertices and pairwise disjoint interiors. Suppress the internal degree-two vertices and their endpoints form K₃,₃. This subdivision witnesses nonplanarity.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
const witness = discrete.planarity(discrete.petersen()).kuratowski;
console.log([witness.kind, witness.paths]);
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Small planar embeddings, named graphs and subdivisions with roughly 4–20 vertices; genus is a different search from planarity.
For this problem type. Hand graph examples usually have 3–12 vertices. Include edges or graph density as a second input because exact searches of the same order can differ sharply.
Focal example. The code above passed its displayed check in 0.726 ms on Node.
Related workload in this unit.discrete.isBipartite · cycle vertices. Baseline test points across courses 3, 4, 5, 12, 30. A cycle has a bipartition precisely when its length is even.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 10,000 (21.70 ms, 92.2 MiB peak process RSS). The runs did not locate a ceiling for this family. Graph traversal depends on vertices and edges. A long sparse cycle has far fewer edges than a dense graph of the same order.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.252
75.7
4
Baseline
Passed
0.382
74.8
5
Baseline
Passed
0.406
75
12
Baseline
Passed
0.424
74.9
30
Baseline
Passed
0.349
75.7
100
Stretch
Passed
0.609
75.9
1,000
Stretch
Passed
20.72
77.9
10,000
Stretch
Passed
21.70
92.2
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.planarity · 1 passing test case, 1 distinct argument description
The cube graph is planar with 8 vertices and 12 edges. How many faces does a plane drawing have?
Worked solution
: .
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
const g = discrete.platonic("cube");
const p = discrete.planarity(g);
console.log([p.planar, p.faces[0].length, g.order - g.size + p.faces[0].length]);
Checked output
[true, 6, 2]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Small planar embeddings, named graphs and subdivisions with roughly 4–20 vertices; genus is a different search from planarity.
For this problem type. Hand graph examples usually have 3–12 vertices. Include edges or graph density as a second input because exact searches of the same order can differ sharply.
Focal example. The code above passed its displayed check in 0.683 ms on Node.
Related workload in this unit.discrete.isBipartite · cycle vertices. Baseline test points across courses 3, 4, 5, 12, 30. A cycle has a bipartition precisely when its length is even.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 10,000 (21.70 ms, 92.2 MiB peak process RSS). The runs did not locate a ceiling for this family. Graph traversal depends on vertices and edges. A long sparse cycle has far fewer edges than a dense graph of the same order.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.252
75.7
4
Baseline
Passed
0.382
74.8
5
Baseline
Passed
0.406
75
12
Baseline
Passed
0.424
74.9
30
Baseline
Passed
0.349
75.7
100
Stretch
Passed
0.609
75.9
1,000
Stretch
Passed
20.72
77.9
10,000
Stretch
Passed
21.70
92.2
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.platonic · 9 passing test cases, 5 distinct argument descriptions
What is the genus of (the least genus of a surface it embeds in)?
Worked solution
It is not planar, and it embeds in the torus: genus 1. (.)
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
const t = discrete.genus(discrete.complete(5));
console.log(
[discrete.isPlanar(discrete.complete(5)), t.genus, t.proven, discrete.embeddingGenus(discrete.complete(5), t.blocks[0].rotation).faces.length]
);
Checked output
[false, 1, true, 5]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Small planar embeddings, named graphs and subdivisions with roughly 4–20 vertices; genus is a different search from planarity.
For this problem type. Use 3–20 labeled vertices and a stated edge list. For a walk count also supply length, usually a single digit in a hand problem.
Focal example. The code above passed its displayed check in 2.96 ms on Node.
Related workload in this unit.discrete.isBipartite · cycle vertices. Baseline test points across courses 3, 4, 5, 12, 30. A cycle has a bipartition precisely when its length is even.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 10,000 (21.70 ms, 92.2 MiB peak process RSS). The runs did not locate a ceiling for this family. Graph traversal depends on vertices and edges. A long sparse cycle has far fewer edges than a dense graph of the same order.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.252
75.7
4
Baseline
Passed
0.382
74.8
5
Baseline
Passed
0.406
75
12
Baseline
Passed
0.424
74.9
30
Baseline
Passed
0.349
75.7
100
Stretch
Passed
0.609
75.9
1,000
Stretch
Passed
20.72
77.9
10,000
Stretch
Passed
21.70
92.2
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.genus · 5 passing test cases, 1 distinct argument description
20 triangular faces, , five faces at each vertex so . .
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as geo from "@ratmath/geo";
const P = geo.solids.icosahedron();
console.log([P.V, P.E, P.F, P.euler]);
Checked output
[12, 30, 20, 2]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Small planar embeddings, named graphs and subdivisions with roughly 4–20 vertices; genus is a different search from planarity.
For this problem type. This example selects a built-in theorem or solid. The input is a discrete choice from a finite catalog. The displayed call has no freely scalable numeric argument.
Focal example. The code above passed its displayed check in 144 ms on Node.
Same API, measured input family.geo.solids · number of catalog solids checked. Baseline test points across courses 1, 2, 3, 5. Compare the vertex, edge and face counts with the known convex polyhedra and verify V−E+F=2 for each.
Practical limit. Largest passing sample 9 (939 ms, 99.7 MiB peak process RSS). The first sampled passing call above 100 ms used 5 (444 ms). The runs did not locate a ceiling for this family. These inputs select named solids from a finite catalog. Mesh processing for an arbitrary number of faces would be a different operation.
Measured times, memory and outcomes
number of catalog solids checked · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
1.23
75.4
2
Baseline
Passed
3.73
75.8
3
Baseline
Passed
3.42
76.6
5
Baseline
Passed
444
94.9
7
Stretch
Passed
437
95.5
9
Stretch
Passed
939
99.7
Each row measures the stated fixture. Other inputs to this API can take different paths. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
geo.solids.icosahedron · 2 passing test cases, 1 distinct argument description
Direct calculation@ratmath/discrete · @ratmath/geo
Problem
For the Petersen graph as a 1-dimensional complex, find and the rank of .
Worked solution
. It is connected, so and independent cycles.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
import * as geo from "@ratmath/geo";
const P = geo.simplicial.fromGraph(discrete.petersen());
console.log([P.eulerCharacteristic, P.betti()[1]]);
Checked output
[-5, 6]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Small planar embeddings, named graphs and subdivisions with roughly 4–20 vertices; genus is a different search from planarity.
For this problem type. Use 3–20 labeled vertices and a stated edge list. For a walk count also supply length, usually a single digit in a hand problem.
Focal example. The code above passed its displayed check in 2.26 ms on Node.
Related workload in this unit.geo.countTopologies · labeled points. Baseline test points across courses 1, 2, 3, 4. Compare the counts of labeled topologies with 1,4,29,355,6942,209527.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 5 (941 ms, 88.6 MiB peak process RSS). Library refusal at 6. The first sampled passing call above 100 ms used 5 (941 ms). The number of labeled topologies grows rapidly. An explicit census on a finite set is much harder than checking a given topology.
Measured times, memory and outcomes
labeled points · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
0.172
75
2
Baseline
Passed
0.209
75.4
3
Baseline
Passed
0.298
76.1
4
Baseline
Passed
18.86
77.3
5
Stretch
Passed
941
88.6
6
Stretch
Library refusal · GeoError: counting by preorders is limited to n ≤ 5 here (6 points have 209527 topologies)
0.170
75.6
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
geo.simplicial.fromGraph · 1 passing test case, 1 distinct argument description
Can a simple planar graph on six vertices have 14 edges?
Worked solution
For at least three vertices E≤3V−6, giving at most twelve.
Using RatMath
Put the arithmetic inside the R tag so RatMath parses the literals. Keep fractions as ratios throughout the calculation and attach the units from the problem to the result.
JavaScript module
import { R } from "@ratmath/core";
console.log(String(R`3*6-6`));
Checked output
12
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Small planar embeddings, named graphs and subdivisions with roughly 4–20 vertices; genus is a different search from planarity.
Focal example. The code above passed its displayed check in 0.114 ms on Node.
Same arithmetic expression. Replaced its first numeral 3 with 0, 1, 2, 7, 12, 100, 1000, -3, 1/2. All 9 defined variants agreed exactly with Python’s rational arithmetic. This varies the arithmetic operation while holding the rest of the expression fixed.
Related workload in this unit.core.R · whole-number operand. Baseline test points across courses 0, 1, 10, 20, 100, 1,000, 1,000,000. (n+7)(n−3) by independent BigInt arithmetic.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 9,007,199,254,740,991 (1.67 ms, 75.3 MiB peak process RSS). The runs did not locate a ceiling for this family. Exact integer arithmetic grows with operand bit length. Enter large integers as decimal strings or BigInts before any JavaScript Number conversion.
Measured times, memory and outcomes
whole-number operand · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
0
Baseline
Passed
1.75
75
1
Baseline
Passed
1.70
75.7
10
Baseline
Passed
1.78
75.1
20
Baseline
Passed
1.88
75.4
100
Baseline
Passed
1.55
75.4
1,000
Baseline
Passed
1.36
75.3
1,000,000
Baseline
Passed
1.39
74.8
1,000,000,000
Stretch
Passed
1.69
76.3
9,007,199,254,740,991
Stretch
Passed
1.67
75.3
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
core.R · 2 passing test cases, 10 distinct argument descriptions
Use the face-length bound to explain why K₃,₃ is nonplanar.
Worked solution
In a planar embedding its faces would have length at least four. Euler then gives E≤2V−4=8 while K₃,₃ has 9 edges.
Working without a calculator
Use the argument or construction in the worked solution. This lesson assigns the reasoning to the student.
Input range and limits
Typical inputs for this unit. Small planar embeddings, named graphs and subdivisions with roughly 4–20 vertices; genus is a different search from planarity.
Scope of verification. This day asks for a hand argument, construction or interpretation. The worked instance gives the input. General claims need the reasoning shown above. A measured time, memory ceiling or finite input sweep would not verify that claim.
Day 25 / 40 · Coloring and extremal problems
Chromatic number
Direct calculation@ratmath/discrete
Problem
Find the chromatic number of the wheel with 5 spokes (a hub joined to every vertex of ).
Worked solution
The odd rim needs 3 colours and the hub, adjacent to all of them, needs a fourth: .
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
console.log(discrete.chromaticNumber(discrete.wheel(5)).number);
Checked output
4
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. About 3–15 vertices for hand coloring and exhaustive classroom searches; density and symmetry affect search cost.
For this problem type. Hand graph examples usually have 3–12 vertices. Include edges or graph density as a second input because exact searches of the same order can differ sharply.
Focal example. The code above passed its displayed check in 0.240 ms on Node.
Same API, measured input family.discrete.chromaticNumber · cycle vertices. Baseline test points across courses 3, 4, 5, 10, 15. Odd cycles require three colours, even cycles two.
Practical limit. Largest passing sample 101 (8.06 ms, 79 MiB peak process RSS). The runs did not locate a ceiling for this family. Cycles are easy to color. Exact coloring, clique and isomorphism searches can take much longer on less structured graphs of the same size.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.592
74.6
4
Baseline
Passed
0.684
75
5
Baseline
Passed
1.15
74.9
10
Baseline
Passed
0.866
74.7
15
Baseline
Passed
1.74
75.6
25
Stretch
Passed
1.60
75.6
50
Stretch
Passed
1.17
76
101
Stretch
Passed
8.06
79
Each row measures the stated fixture. Other inputs to this API can take different paths. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.chromaticNumber · 1 passing test case, 1 distinct argument description
Implementation limit. The default coloring search budget is 2,000,000 steps. Difficulty depends on graph structure. Source at the tested revision
Day 26 / 40 · Coloring and extremal problems
Chromatic polynomial
Direct calculation@ratmath/discrete
Problem
Find the chromatic polynomial of .
Worked solution
: .
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
console.log(String(discrete.chromaticPolynomial(discrete.cycleGraph(4))));
Checked output
k^4 − 4k^3 + 6k^2 − 3k
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. About 3–15 vertices for hand coloring and exhaustive classroom searches; density and symmetry affect search cost.
For this problem type. Hand graph examples usually have 3–12 vertices. Include edges or graph density as a second input because exact searches of the same order can differ sharply.
Focal example. The code above passed its displayed check in 0.644 ms on Node.
Related workload in this unit.discrete.chromaticNumber · cycle vertices. Baseline test points across courses 3, 4, 5, 10, 15. Odd cycles require three colours, even cycles two.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 101 (8.06 ms, 79 MiB peak process RSS). The runs did not locate a ceiling for this family. Cycles are easy to color. Exact coloring, clique and isomorphism searches can take much longer on less structured graphs of the same size.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.592
74.6
4
Baseline
Passed
0.684
75
5
Baseline
Passed
1.15
74.9
10
Baseline
Passed
0.866
74.7
15
Baseline
Passed
1.74
75.6
25
Stretch
Passed
1.60
75.6
50
Stretch
Passed
1.17
76
101
Stretch
Passed
8.06
79
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.chromaticPolynomial · 1 passing test case, 1 distinct argument description
What is the largest number of edges in a triangle-free graph on 6 vertices?
Worked solution
Mantel/Turán: , attained by .
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
console.log(discrete.turan(6, 2).size);
Checked output
9
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. About 3–15 vertices for hand coloring and exhaustive classroom searches; density and symmetry affect search cost.
Focal example. The code above passed its displayed check in 0.136 ms on Node.
Related workload in this unit.discrete.chromaticNumber · cycle vertices. Baseline test points across courses 3, 4, 5, 10, 15. Odd cycles require three colours, even cycles two.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 101 (8.06 ms, 79 MiB peak process RSS). The runs did not locate a ceiling for this family. Cycles are easy to color. Exact coloring, clique and isomorphism searches can take much longer on less structured graphs of the same size.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.592
74.6
4
Baseline
Passed
0.684
75
5
Baseline
Passed
1.15
74.9
10
Baseline
Passed
0.866
74.7
15
Baseline
Passed
1.74
75.6
25
Stretch
Passed
1.60
75.6
50
Stretch
Passed
1.17
76
101
Stretch
Passed
8.06
79
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.turan · 1 passing test case, 1 distinct argument description
Find the clique number of the Petersen graph and of its complement.
Worked solution
Petersen has girth 5, so it has no triangle: . A clique in the complement is an independent set in , so .
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
const P = discrete.petersen();
console.log([discrete.maximumClique(P).length, discrete.maximumClique(P.complement()).length]);
Checked output
[2, 4]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. About 3–15 vertices for hand coloring and exhaustive classroom searches; density and symmetry affect search cost.
For this problem type. Hand graph examples usually have 3–12 vertices. Include edges or graph density as a second input because exact searches of the same order can differ sharply.
Focal example. The code above passed its displayed check in 0.467 ms on Node.
Related workload in this unit.discrete.chromaticNumber · cycle vertices. Baseline test points across courses 3, 4, 5, 10, 15. Odd cycles require three colours, even cycles two.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 101 (8.06 ms, 79 MiB peak process RSS). The runs did not locate a ceiling for this family. Cycles are easy to color. Exact coloring, clique and isomorphism searches can take much longer on less structured graphs of the same size.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.592
74.6
4
Baseline
Passed
0.684
75
5
Baseline
Passed
1.15
74.9
10
Baseline
Passed
0.866
74.7
15
Baseline
Passed
1.74
75.6
25
Stretch
Passed
1.60
75.6
50
Stretch
Passed
1.17
76
101
Stretch
Passed
8.06
79
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.petersen · 15 passing test cases, 1 distinct argument description
Is the cube graph bipartite? Is the Petersen graph?
Worked solution
: yes, split by the parity of the number of 1s. Petersen: no, it has 5-cycles.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
console.log(
[discrete.isBipartite(discrete.hypercube(3)), discrete.isBipartite(discrete.petersen())]
);
Checked output
[true, false]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. About 3–15 vertices for hand coloring and exhaustive classroom searches; density and symmetry affect search cost.
For this problem type. Use 3–20 labeled vertices and a stated edge list. For a walk count also supply length, usually a single digit in a hand problem.
Focal example. The code above passed its displayed check in 0.791 ms on Node.
Same API, measured input family.discrete.isBipartite · cycle vertices. Baseline test points across courses 3, 4, 5, 12, 30. A cycle has a bipartition precisely when its length is even.
Practical limit. Largest passing sample 10,000 (21.70 ms, 92.2 MiB peak process RSS). The runs did not locate a ceiling for this family. Graph traversal depends on vertices and edges. A long sparse cycle has far fewer edges than a dense graph of the same order.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.252
75.7
4
Baseline
Passed
0.382
74.8
5
Baseline
Passed
0.406
75
12
Baseline
Passed
0.424
74.9
30
Baseline
Passed
0.349
75.7
100
Stretch
Passed
0.609
75.9
1,000
Stretch
Passed
20.72
77.9
10,000
Stretch
Passed
21.70
92.2
Each row measures the stated fixture. Other inputs to this API can take different paths. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.hypercube · 7 passing test cases, 2 distinct argument descriptions
How many people must be in a room to be sure that three share a birth month?
Worked solution
.
Using RatMath
The call tests the proposed threshold of 25. To show minimality, distribute 24 people evenly across the 12 months.
JavaScript module
import * as discrete from "@ratmath/discrete";
console.log(discrete.pigeonhole(25, 12));
Checked output
{ atLeast: 3n, atMost: 2n, forced: true, statement: "25 items in 12 boxes: some box holds at least 3" }
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. About 3–15 vertices for hand coloring and exhaustive classroom searches; density and symmetry affect search cost.
Focal example. The code above passed its displayed check in 0.179 ms on Node.
Related workload in this unit.discrete.chromaticNumber · cycle vertices. Baseline test points across courses 3, 4, 5, 10, 15. Odd cycles require three colours, even cycles two.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 101 (8.06 ms, 79 MiB peak process RSS). The runs did not locate a ceiling for this family. Cycles are easy to color. Exact coloring, clique and isomorphism searches can take much longer on less structured graphs of the same size.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.592
74.6
4
Baseline
Passed
0.684
75
5
Baseline
Passed
1.15
74.9
10
Baseline
Passed
0.866
74.7
15
Baseline
Passed
1.74
75.6
25
Stretch
Passed
1.60
75.6
50
Stretch
Passed
1.17
76
101
Stretch
Passed
8.06
79
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.pigeonhole · 1 passing test case, 3 distinct argument descriptions
What is the relation between a vertex cover and the complement of an independent set?
Worked solution
A set is independent exactly when its complement meets every edge. This equivalence translates minimum covers into maximum independent sets.
Working without a calculator
Use the argument or construction in the worked solution. This lesson assigns the reasoning to the student.
Input range and limits
Typical inputs for this unit. About 3–15 vertices for hand coloring and exhaustive classroom searches; density and symmetry affect search cost.
Scope of verification. This day asks for a hand argument, construction or interpretation. The worked instance gives the input. General claims need the reasoning shown above. A measured time, memory ceiling or finite input sweep would not verify that claim.
Day 32 / 40 · Coloring and extremal problems
Odd cycles
Direct calculation@ratmath/discrete
Problem
How many colors are necessary and sufficient for a cycle of length five?
Worked solution
Alternating two colors fails on the closing edge. A third color on the last vertex completes a proper coloring.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
console.log(discrete.chromaticNumber(discrete.cycleGraph(5)).number);
Checked output
3
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. About 3–15 vertices for hand coloring and exhaustive classroom searches; density and symmetry affect search cost.
For this problem type. Hand graph examples usually have 3–12 vertices. Include edges or graph density as a second input because exact searches of the same order can differ sharply.
Focal example. The code above passed its displayed check in 0.411 ms on Node.
Same API, measured input family.discrete.chromaticNumber · cycle vertices. Baseline test points across courses 3, 4, 5, 10, 15. Odd cycles require three colours, even cycles two.
Practical limit. Largest passing sample 101 (8.06 ms, 79 MiB peak process RSS). The runs did not locate a ceiling for this family. Cycles are easy to color. Exact coloring, clique and isomorphism searches can take much longer on less structured graphs of the same size.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.592
74.6
4
Baseline
Passed
0.684
75
5
Baseline
Passed
1.15
74.9
10
Baseline
Passed
0.866
74.7
15
Baseline
Passed
1.74
75.6
25
Stretch
Passed
1.60
75.6
50
Stretch
Passed
1.17
76
101
Stretch
Passed
8.06
79
Each row measures the stated fixture. Other inputs to this API can take different paths. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.chromaticNumber · 1 passing test case, 1 distinct argument description
Implementation limit. The default coloring search budget is 2,000,000 steps. Difficulty depends on graph structure. Source at the tested revision
Day 33 / 40 · Graph algorithms and invariants
Matchings
Direct calculation@ratmath/discrete
Problem
What is the size of a maximum matching in ? Is it perfect?
Worked solution
Hall's condition holds (every set of left vertices has 3 neighbours), so there is a perfect matching of size 3.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
const m = discrete.maximumMatching(discrete.completeBipartite(3, 3));
console.log([m.size, m.perfect]);
Checked output
[3, true]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Matching, flow and invariants on graphs usually with a few to tens of vertices and small integer capacities.
For this problem type. Use about 2–8 agents on each side or 3–12 network vertices. Store costs, capacities and missing or forbidden edges explicitly.
Focal example. The code above passed its displayed check in 0.708 ms on Node.
Same API, measured input family.discrete.maximumMatching · vertices per side. Baseline test points across courses 1, 2, 5, 10. K_(n,n) has a diagonal perfect matching of size n.
Practical limit. Largest passing sample 100 (102 ms, 125.5 MiB peak process RSS). The first sampled passing call above 100 ms used 100 (102 ms). The runs did not locate a ceiling for this family. Complete bipartite input has n² edges. Verifying a matching uses its vertices and edges. More general optimization objectives need their own check.
Measured times, memory and outcomes
vertices per side · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
0.869
75.2
2
Baseline
Passed
0.511
74.2
5
Baseline
Passed
0.783
76.1
10
Baseline
Passed
1.21
75
25
Stretch
Passed
4.06
78.9
50
Stretch
Passed
24.22
91.6
100
Stretch
Passed
102
125.5
Each row measures the stated fixture. Other inputs to this API can take different paths. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.maximumMatching · 1 passing test case, 1 distinct argument description
In the network (3), (2), (1), (2), (3), find the maximum flow from to .
Worked solution
The cut has capacity . Flow: 2, 1, 2: total 5. Max flow min cut .
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
const g = discrete.digraph([["s", "a", 3], ["s", "b", 2], ["a", "b", 1], ["a", "t", 2], ["b", "t", 3]]);
console.log(String(discrete.maxFlow(g, "s", "t").value));
Checked output
5
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Matching, flow and invariants on graphs usually with a few to tens of vertices and small integer capacities.
For this problem type. Use about 2–8 agents on each side or 3–12 network vertices. Store costs, capacities and missing or forbidden edges explicitly.
Focal example. The code above passed its displayed check in 0.465 ms on Node.
Related workload in this unit.discrete.maximumMatching · vertices per side. Baseline test points across courses 1, 2, 5, 10. K_(n,n) has a diagonal perfect matching of size n.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 100 (102 ms, 125.5 MiB peak process RSS). The first sampled passing call above 100 ms used 100 (102 ms). The runs did not locate a ceiling for this family. Complete bipartite input has n² edges. Verifying a matching uses its vertices and edges. More general optimization objectives need their own check.
Measured times, memory and outcomes
vertices per side · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
0.869
75.2
2
Baseline
Passed
0.511
74.2
5
Baseline
Passed
0.783
76.1
10
Baseline
Passed
1.21
75
25
Stretch
Passed
4.06
78.9
50
Stretch
Passed
24.22
91.6
100
Stretch
Passed
102
125.5
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.digraph · 3 passing test cases, 3 distinct argument descriptions
and two disjoint triangles are both 2-regular on 6 vertices. Are they isomorphic?
Worked solution
No: is connected and the triangles are not (also, one has girth 6 and the other 3).
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
console.log(
discrete.isIsomorphic(discrete.cycleGraph(6), discrete.disjointUnion(discrete.cycleGraph(3), discrete.cycleGraph(3)))
);
Checked output
false
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Matching, flow and invariants on graphs usually with a few to tens of vertices and small integer capacities.
For this problem type. Hand graph examples usually have 3–12 vertices. Include edges or graph density as a second input because exact searches of the same order can differ sharply.
Focal example. The code above passed its displayed check in 0.988 ms on Node.
Related workload in this unit.discrete.chromaticNumber · cycle vertices. Baseline test points across courses 3, 4, 5, 10, 15. Odd cycles require three colours, even cycles two.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 101 (8.06 ms, 79 MiB peak process RSS). The runs did not locate a ceiling for this family. Cycles are easy to color. Exact coloring, clique and isomorphism searches can take much longer on less structured graphs of the same size.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.592
74.6
4
Baseline
Passed
0.684
75
5
Baseline
Passed
1.15
74.9
10
Baseline
Passed
0.866
74.7
15
Baseline
Passed
1.74
75.6
25
Stretch
Passed
1.60
75.6
50
Stretch
Passed
1.17
76
101
Stretch
Passed
8.06
79
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.isIsomorphic · 1 passing test case, 1 distinct argument description
; has eigenvalues 4, 0, 0, 0, so has 3 and (three times).
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
console.log(
discrete.spectrum(discrete.complete(4)).eigenvalues.map((e) => [e.text, e.multiplicity])
);
Checked output
[["−1", 3], ["3", 1]]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Matching, flow and invariants on graphs usually with a few to tens of vertices and small integer capacities.
For this problem type. Use 3–20 labeled vertices and a stated edge list. For a walk count also supply length, usually a single digit in a hand problem.
Focal example. The code above passed its displayed check in 0.479 ms on Node.
Related workload in this unit.discrete.isBipartite · cycle vertices. Baseline test points across courses 3, 4, 5, 12, 30. A cycle has a bipartition precisely when its length is even.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 10,000 (21.70 ms, 92.2 MiB peak process RSS). The runs did not locate a ceiling for this family. Graph traversal depends on vertices and edges. A long sparse cycle has far fewer edges than a dense graph of the same order.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.252
75.7
4
Baseline
Passed
0.382
74.8
5
Baseline
Passed
0.406
75
12
Baseline
Passed
0.424
74.9
30
Baseline
Passed
0.349
75.7
100
Stretch
Passed
0.609
75.9
1,000
Stretch
Passed
20.72
77.9
10,000
Stretch
Passed
21.70
92.2
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.spectrum · 1 passing test case, 1 distinct argument description
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Matching, flow and invariants on graphs usually with a few to tens of vertices and small integer capacities.
For this problem type. Use 3–20 labeled vertices and a stated edge list. For a walk count also supply length, usually a single digit in a hand problem.
Focal example. The code above passed its displayed check in 0.494 ms on Node.
Related workload in this unit.discrete.isBipartite · cycle vertices. Baseline test points across courses 3, 4, 5, 12, 30. A cycle has a bipartition precisely when its length is even.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 10,000 (21.70 ms, 92.2 MiB peak process RSS). The runs did not locate a ceiling for this family. Graph traversal depends on vertices and edges. A long sparse cycle has far fewer edges than a dense graph of the same order.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.252
75.7
4
Baseline
Passed
0.382
74.8
5
Baseline
Passed
0.406
75
12
Baseline
Passed
0.424
74.9
30
Baseline
Passed
0.349
75.7
100
Stretch
Passed
0.609
75.9
1,000
Stretch
Passed
20.72
77.9
10,000
Stretch
Passed
21.70
92.2
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.graph · 10 passing test cases, 21 distinct argument descriptions
Proposers A: x > y and B: y > x; receivers x: B > A and y: A > B. Run Gale–Shapley with A and B proposing.
Worked solution
A proposes to x, B to y; both are accepted and nobody is rejected. Matching A–x, B–y: stable (and best for the proposers), with no blocking pair.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
const m = discrete.stableMatching({ A: ["x", "y"], B: ["y", "x"] }, { x: ["B", "A"], y: ["A", "B"] });
console.log([m.matching, m.blockingPairs]);
Checked output
[{ A: "x", B: "y" }, []]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Matching, flow and invariants on graphs usually with a few to tens of vertices and small integer capacities.
For this problem type. Use about 2–8 agents on each side or 3–12 network vertices. Store costs, capacities and missing or forbidden edges explicitly.
Focal example. The code above passed its displayed check in 0.298 ms on Node.
Related workload in this unit.discrete.maximumMatching · vertices per side. Baseline test points across courses 1, 2, 5, 10. K_(n,n) has a diagonal perfect matching of size n.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 100 (102 ms, 125.5 MiB peak process RSS). The first sampled passing call above 100 ms used 100 (102 ms). The runs did not locate a ceiling for this family. Complete bipartite input has n² edges. Verifying a matching uses its vertices and edges. More general optimization objectives need their own check.
Measured times, memory and outcomes
vertices per side · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
0.869
75.2
2
Baseline
Passed
0.511
74.2
5
Baseline
Passed
0.783
76.1
10
Baseline
Passed
1.21
75
25
Stretch
Passed
4.06
78.9
50
Stretch
Passed
24.22
91.6
100
Stretch
Passed
102
125.5
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.stableMatching · 1 passing test case, 1 distinct argument description
Three applicants collectively qualify for only two jobs. Can a matching place all three?
Worked solution
Their neighborhood has size below the size of the applicant set, violating Hall's necessary condition.
Using RatMath
Use the result for the computational step. The worked solution explains the remaining mathematical inference.
JavaScript module
import * as discrete from "@ratmath/discrete";
console.log(discrete.maximumMatching(discrete.completeBipartite(3,2)).size);
Checked output
2
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Matching, flow and invariants on graphs usually with a few to tens of vertices and small integer capacities.
For this problem type. Use about 2–8 agents on each side or 3–12 network vertices. Store costs, capacities and missing or forbidden edges explicitly.
Focal example. The code above passed its displayed check in 0.306 ms on Node.
Same API, measured input family.discrete.maximumMatching · vertices per side. Baseline test points across courses 1, 2, 5, 10. K_(n,n) has a diagonal perfect matching of size n.
Practical limit. Largest passing sample 100 (102 ms, 125.5 MiB peak process RSS). The first sampled passing call above 100 ms used 100 (102 ms). The runs did not locate a ceiling for this family. Complete bipartite input has n² edges. Verifying a matching uses its vertices and edges. More general optimization objectives need their own check.
Measured times, memory and outcomes
vertices per side · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
0.869
75.2
2
Baseline
Passed
0.511
74.2
5
Baseline
Passed
0.783
76.1
10
Baseline
Passed
1.21
75
25
Stretch
Passed
4.06
78.9
50
Stretch
Passed
24.22
91.6
100
Stretch
Passed
102
125.5
Each row measures the stated fixture. Other inputs to this API can take different paths. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.maximumMatching · 1 passing test case, 1 distinct argument description
Are a 6-cycle and two disjoint triangles isomorphic?
Worked solution
Both have six vertices all of degree two. Only the cycle is connected, which distinguishes them.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as discrete from "@ratmath/discrete";
console.log(
discrete.isIsomorphic(discrete.cycleGraph(6),discrete.disjointUnion(discrete.cycleGraph(3),discrete.cycleGraph(3)))
);
Checked output
false
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Matching, flow and invariants on graphs usually with a few to tens of vertices and small integer capacities.
For this problem type. Hand graph examples usually have 3–12 vertices. Include edges or graph density as a second input because exact searches of the same order can differ sharply.
Focal example. The code above passed its displayed check in 0.274 ms on Node.
Related workload in this unit.discrete.chromaticNumber · cycle vertices. Baseline test points across courses 3, 4, 5, 10, 15. Odd cycles require three colours, even cycles two.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 101 (8.06 ms, 79 MiB peak process RSS). The runs did not locate a ceiling for this family. Cycles are easy to color. Exact coloring, clique and isomorphism searches can take much longer on less structured graphs of the same size.
Measured times, memory and outcomes
cycle vertices · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
3
Baseline
Passed
0.592
74.6
4
Baseline
Passed
0.684
75
5
Baseline
Passed
1.15
74.9
10
Baseline
Passed
0.866
74.7
15
Baseline
Passed
1.74
75.6
25
Stretch
Passed
1.60
75.6
50
Stretch
Passed
1.17
76
101
Stretch
Passed
8.06
79
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
discrete.isIsomorphic · 1 passing test case, 1 distinct argument description