Graphs
a graph is a mathematical structure for representing relationships
- a graph consists of a set of nodes (or vertices) connected by edges (or arcs)
- some graphs are directed: edges are from one node to another node. directed graphs are also called digraphs.
- other graphs are undirected: edges are to indicate if two nodes are connected; no sense of direction
- there are some graphs called mixed graphs that allow for both types of edges, but they’re fairly uncommon and we won’t talk about them.
- unless specified otherwise, “graph” means “undirected graph”
Formalizing Graphs
- to define a graph, we need to specify what the nodes are, and which edges are in the graph.
- nodes can be pretty much anything; what about edges?
- an unordered pair is a set $\{ a,b \}$ of two elements $a \neq b.$ (sets are unordered)
- an undirected graph is an ordered pair $G=(V,E)$, where
- $V$ is a set of nodes, which can be anything, and
- $E$ is a set of edges, which are unordered pairs of nodes drawn from $V$.
- a directed graph is exactly the same, except $E$ is a set of ordered pairs of nodes in $V$.
- Note: a “self-loop”, i.e. an edge from a node to itself, is possible in a digraph but not in an undirected graph.
CS 103 Midterm
- Lectures 00-05 and topics covered in PS1-PS2.
- You can bring a double-sided, 8.5” by 11” sheet of notes with you to the exam, decorated however you’d like.
- recommendation: hand write it
- you can revise and resubmit, new score is max of old score and 85% of your new score.
- first midterm is in STLC 111 (for last name A-L), Monday, October 24th, 7-10PM
- extra practice problems, a set of 24 practice problems on the topics covered by the upcoming midterm
- many are just old midterm questions!
Motivating problems.