CPSC 203, 2025 W1
October 28, 2025


How much work is done? Let \(n\) denote the size of the image, \(n = width \cdot height\)
Read image:
Choose centers:
Build new image:

We evaluate algorithms by looking at how their running times change as a function of the input size (n).
Loosely, algorithm A is faster than algorithm B if A’s running time is eventually less than B’s.

A Graph is a collection of vertices, and edges between them. They’re used as a general model for many problems.
In our images every ____________ is a vertex, and every ____________ is an edge.
Our fast algorithm for Voronoi Art mirrors a classic algorithm on graphs called Breadth First Search.
Breadth-first search (BFS) is an algorithm for traversing or searching tree or graph data structures. It starts at the tree root (or some arbitrary node of a graph), and explores all of the neighbor nodes at the present depth prior to moving on to the nodes at the next depth level. (–Wikipedia)

Graph \(G = (V, E)\)
Degree of a vertex:

Graph \(G = (V, E)\)
Labels:
Neighbors:
What’s special about the vertex labels of this graph?

Graph \(G = (V, E)\)
A graph is complete if it contains all possible edges.
How many edges in a complete graph of n vertices?


Graph \(G = (V, E)\)
Path:

This graph can be used to quickly calculate whether a given number is divisible by 7.
Start at the circle node at the top. For each digit \(d\) in the given number, follow \(d\) blue (solid) edges in succession. As you move from one digit to the next, follow 1 red (dashed) edge. If you end up back at the circle node, your number is divisible by 7.
3703

Graph \(G = (V, E)\)
Planar Graph:
A graph \(G\) is defined by a set of vertices \(V\), and a set of edges \(E\).
Algorithm running time is typically described using the number of vertices, but execution usually depends on the number of edges, so we must understand the relationship between them.
Suppose I tell you a connected graph has 100 vertices. What do we know about the number of edges?

At least __________ edges because the graph is connected.
At most _________ edges which occurs when the graph is complete.
Suppose I tell you a graph has 28 vertices, each with degree 3. How many edges does it have?

The following are equivalent:
Suppose I drop my graph and it shatters into pieces. If I tell you the degree of each of the vertices, can you reconstruct the graph?
An algorithm for finding a graph, given a degree sequence, is described in the practice problems.

Trace each graph without lifting your pencil and without revisiting an edge.
Can all graphs be traced?
What characterizes those that cannot?
Social Network
Graph \(G = (V, E)\)
Connected Graph:
Connected Component: