BS Artificial Intelligence · Semester 1 · Case Study 2

Discrete Mathematics for BSAI

Campus Inspection and Delivery Robot

Two route questions on one small network

Dr. Hira Benish
Associate Professor & HoD, Mathematics
Math & AI Lab, Mathematics Behind AI

Case Study 2 · Dr. Hira BenishBegin reading  

01 · Scenario: A Campus Inspection and Delivery Robot

A campus team draws a small walkway network. On inspection day a robot should cover every walkway exactly once. On delivery day it should visit every building exactly once. These sound similar but ask about different parts of a graph.

The network is a classroom abstraction. Every walkway is usable in both directions and every edge is treated as one unit for this case. Safety, time, battery and accessibility constraints are not supplied.

Application fieldTransparent route planning for a small campus network
Mathematical focusGraph models, degree, Euler trails, Hamiltonian paths/cycles, planarity and coloring
Course placementWeeks 13–14 major graph case; Week 16 comparison
ToolDraw and trace by hand; optional small Python check

Learning outcomes

Build a labeled graph from a network; verify an Euler trail by degree and edge trace; exhibit a Hamiltonian route; check planar face counts and a small proper coloring; and interpret how a changed edge affects the decision.

Investigation questions

  1. Can the robot inspect all walkways once? Where must it start and finish?
  2. Can it visit all four buildings once and return to the start?
  3. What changes when one new walkway is added?
  4. Can the two route requirements be checked by the same degree test?
  5. How can a separate conflict graph schedule maintenance tasks?

02 · Draw and Label the Network

Buildings are vertices V={A,B,C,D}. Walkways are undirected edges E={AB,BC,CD,DA,AC}. The four outside edges form a square; AC is a diagonal. A route written A→B→C uses walkways AB and BC. It does not automatically use AC.

Square campus graph A B C D around the outside and diagonal A C ABCD
Figure 1. Four buildings, five walkways. Routes may move in either direction along an edge.
BuildingNeighbor listDegree
AB, C, D3
BA, C2
CA, B, D3
DA, C2

The degree sum is 3+2+3+2=10, which equals twice the five edges. This cross-check catches a missed or duplicated walkway in the table.

03 · Inspection: Each Edge Exactly Once

The network is connected. Exactly two vertices, A and C, have odd degree. The Week 13 Euler criterion therefore permits an open Euler trail starting at one of A,C and ending at the other. It rules out a closed Euler circuit for this graph.

A → B → C → D → A → C
StepWalkway usedUsed before?
1ABNo
2BCNo
3CDNo
4DANo
5ACNo

Every edge in E appears once. The route begins at A and ends at C, matching the two odd-degree vertices. It revisits buildings A and C, which is allowed because the edges are the inspection target.

Meaning of “once”: The route passes through some vertices more than once. That does not violate the edge-once requirement.

04 · Delivery: Each Vertex Once

For delivery, a Hamiltonian path visits every building exactly once. One example is A → B → C → D. If returning to A is required, A → B → C → D → A is a Hamiltonian cycle: A appears again only to close the cycle.

The cycle uses AB, BC, CD and DA; it does not inspect AC. The inspection route used AC but repeated vertices. Both statements are true because they solve different tasks.

TaskMust use exactly onceValid exampleWhat it does not guarantee
Inspect walkwaysEvery edgeA→B→C→D→A→COne visit per building
Deliver to buildingsEvery vertexA→B→C→D→A (cycle)Every walkway inspected

There is no general rule in this module that uses just the number of odd-degree vertices to decide Hamiltonian routes. Here we establish the cycle by showing a valid route.

05 · One New Walkway Changes the Inspection Decision

Add a new walkway BD. The graph now has all six possible edges among A,B,C,D. Its degrees become 3,3,3,3. Because it is connected and has four odd-degree vertices, no Euler trail or circuit can traverse every edge once. But the earlier Hamiltonian cycle A→B→C→D→A still exists: the added edge does not remove that route.

ORIGINAL
5 edges; odd A,C
ADD BD
6 edges; four odd
RESULT
No edge-once trail; vertex cycle remains

Planarity check: The original square and diagonal is a simple connected planar drawing. It has V=4, E=5 and F=3 (two inside regions plus the outside), so 4−5+3=2. The six-edge graph is also planar even if drawing both diagonals inside the square makes them cross: place one vertex inside the triangle formed by the other three and join it to all three. Then V=4, E=6, F=4, and 4−6+4=2.

Misconception warning: A crossing in one particular sketch does not prove a graph is nonplanar. Euler's planar formula is checked on a crossing-free drawing of a connected planar graph and counts the outside face.

06 · Separate Question: Schedule Conflicting Tasks

The maintenance team also has four tasks X,Y,Z,W. Conflicts are XY, YZ, ZX and ZW. These are not the building/walkway edges; this is a separate graph whose vertices are tasks and whose colors are time slots.

X,Y,Z form a triangle, so all three need different slots. W conflicts only with Z, so W may reuse X's slot. One valid coloring is X=Slot 1, Y=Slot 2, Z=Slot 3, W=Slot 1. It uses three slots, and fewer than three are impossible because of the triangle.

Graph questionVertex meansEdge meansDecision
Route graphBuildingWalkwayChoose a valid route
Conflict graphMaintenance taskCannot share a slotColor adjacent tasks differently

Same mathematical word “graph”, different objects and decisions. Always state the interpretation before calculating.

07 · Operational Interpretation and Limits

Inspection decision: On the original network, use an edge-once route from A to C (or reverse). If the robot must return to its starting building without retracing any edge, the original five-edge network cannot satisfy that additional condition. After adding BD, no edge-once inspection route exists under the stated rules.

Delivery decision: A→B→C→D→A is a closed route visiting every building once before returning, in both network versions. It does not cover every walkway.

Practical limitations: The model treats each walkway as undirected and equally usable. It ignores lengths, closures, charging, obstacle detection, traffic, safety and service time. A topologically valid route may still be unsuitable for a physical robot; it must be checked against those operational constraints.

Sensitivity: The added BD walkway makes travel options more numerous but removes the ability to inspect every edge exactly once. More edges do not automatically make the edge-once task easier.

08 · Optional Python Check: Predict → Test → Explain

First draw the graph and find the routes by hand. The code uses a small dictionary: each building name is a key; its list holds neighbors. The len of a neighbor list is its degree. The route check converts each consecutive pair into an unordered edge and compares the resulting set with the supplied walkway set. No new graph package is needed.

neighbors = {
    "A": ["B", "C", "D"],
    "B": ["A", "C"],
    "C": ["A", "B", "D"],
    "D": ["A", "C"]
}
walkways = {frozenset(pair) for pair in [
    ("A", "B"), ("B", "C"), ("C", "D"),
    ("D", "A"), ("A", "C")
]}
inspection = ["A", "B", "C", "D", "A", "C"]
used = [frozenset((inspection[i], inspection[i + 1]))
        for i in range(len(inspection) - 1)]

print({name: len(adj) for name, adj in neighbors.items()})
print("Each walkway once:",
      len(used) == len(set(used)) == len(walkways)
      and set(used) == walkways)

neighbors["B"].append("D")  # add BD in both directions
neighbors["D"].append("B")
print("Odd degrees after BD:",
      [name for name, adj in neighbors.items() if len(adj) % 2 == 1])

Expected: degrees A=3, B=2, C=3, D=2; the proposed inspection route prints True; after BD the odd-degree list is A, B, C, D. frozenset makes AB and BA the same undirected edge. The program checks one given route and degrees; it does not search all routes.

09 · Student Investigation Tasks

Part A · Draw, count and inspect

  1. Draw the original graph from V and E and compute all degrees. Check the degree sum against 2E.
  2. Give a different Euler trail from C to A. List the used edges to verify no repeats.
  3. Explain why an Euler circuit cannot exist on the original network.

Part B · Compare and change

  1. Give a Hamiltonian path starting at D; explain whether it covers all five walkways.
  2. Add BD. Recompute the degrees and explain why a single edge-once trail is impossible. Does a Hamiltonian cycle remain?
  3. Compute V−E+F for both planar versions, counting the outside face. Explain why a crossing in a sketch is not decisive.

Part C · Distinct conflict model and limits

  1. Color tasks X,Y,Z,W with the fewest slots under the stated conflicts. Explain why your number is minimal.
  2. State one physical requirement that could invalidate the topologically valid robot route.
  3. A colleague claims that the robot can use its delivery cycle to inspect all walkways. Identify the omitted edge.

Optional extension: Close walkway AC in the original graph. Recompute degrees and test whether the remaining square has an Euler circuit and a Hamiltonian cycle.

Submission expectation: Two labeled graph drawings (original and changed), a degree table, edge and vertex route traces, the two planar checks, a justified task coloring and a short decision memo with two limitations. The Python output is an optional check after the drawings.

10 · Selected Answers and Instructor Check

TaskAnswer / reasoning checkpoint
1Degrees (A,B,C,D)=(3,2,3,2); total 10=2×5.
2Reverse the worked route: C→A→D→C→B→A uses CA, AD, DC, CB, BA once each.
3A and C are odd. A closed Euler route would require all degrees even.
4For example D→C→B→A visits four distinct buildings. It uses DC, CB, BA only, not all five edges.
5After BD, degrees are (3,3,3,3). Four odd vertices prevent an Euler trail; A→B→C→D→A remains a Hamiltonian cycle.
6Original: V=4, E=5, F=3 gives 2. Changed: V=4, E=6, F=4 gives 2 on a crossing-free drawing. One crossing sketch does not settle planarity.
7Slots X=1,Y=2,Z=3,W=1. The X-Y-Z triangle forces at least three distinct slots.
8–9Any relevant length, closure, battery, safety or direction constraint. The delivery cycle omits diagonal AC.

Extension answer: Removing AC leaves the square AB, BC, CD, DA. Every vertex has degree 2, so A→B→C→D→A is both an Euler circuit (each remaining edge once) and a Hamiltonian cycle (each building once before returning).

Assessment focus: Credit the model interpretation and route verification, not just a list of letters. If this is assigned formally, announce the rubric and grading arrangement separately.

11 · Conclusions and Key Ideas

  • A graph model begins by stating what its vertices and edges mean.
  • Euler reasoning addresses an edge-once route under the connected-graph conditions taught in Week 13.
  • A Hamiltonian route concerns visiting vertices once; exhibit and check an actual route here.
  • Adding an edge can change parity and remove an edge-once trail without removing a vertex cycle.
  • Planarity concerns the existence of a crossing-free drawing; proper coloring concerns conflicts between adjacent vertices.
  • A mathematical route is only one part of a physical operating decision.

Key terms: vertex · edge · degree · connected graph · Euler trail/circuit · Hamiltonian path/cycle · planar drawing · face · proper coloring.