A graph is a pair $(V,E)$, where $V$ is a set of elements called vertices, nodes, or points and $E$ is a set of pairs of vertices called edges or arcs.
Pictorial representation:
Component representation: $(\{a,b,c,d\},\{\{a,c\},\{a,d\},\ldots \{d,c\}\})$.
The edges are not ordered, hence are represented as sets.
Edges can be directed or undirected.
Edges can be weighted.
Edges can cycle.
Adjacent nodes.
Initial and terminal node of an edge.
Edge incident to and from a node.
Degree of a vertes, isolated (0), pendant (1).
In-degree $deg^-(v)$ and out-degree $deg^+(v)$ of a node $v$.
Show these concepts on the above graph during the lecture.
$(V,E)$ is an undirected graph: $2|E| = \sum_{v \in V} deg(v)$. (Handshaking)An undirected graph has an even number of odd degree vertices.
$(V,E)$ is a directed graph: $\sum_{v \in V} deg^-(v) = \sum_{v \in V} deg^+(v) = |E|$.
$n$-cube, complete, bipartite.
Marginal entries are the nodes.
Tabular entries are the arcs (0/1, count, weight) between nodes.
Marginal Column are the nodes.
Marginal row are the arcs.
Tabular entries are ''incidence'' of arc to node.
Every node stores a list of adjiacent nodes.
Compute it for the above graph during the lecture.
$G_1=(V_1,E_1)$ and $G_2=(V_2,E_2)$ are graphs.
$G_1$ and $G_2$ are isomorphic iff there exists bijections $f : V_1 \to V_2$ and $g : E_1 \to E_2$ such that $g((v,w))=(f(v),f(w))$.
If two graphs are isomorphic you can rename nodes and arcs of one to get the other.
Find a (planar = no edge crossing) graph isomorphic to the first example.
Path: a sequence of nodes $v_0,v_1,\ldots,v_n$ such that $(v_{k-1},v_k)$ is an arc.
Circuit: path with $v_0=v_n$.
Simple: path that does not repeat any arc.
Connected graph: there is a path betwen any two nodes.
Euler path/circuit: traverses every arc exactly once.
Has circuit iff connected and every node has even degree.
Hamilton path/circuit: contains every node exactly once.
Example: Traveling Salesperson Problem Hamilton circuit of minimum length.
The problem: find the shortest path from any given vertex to some other vertex in a connected weighted graph.
Symbols: $w$ weights of edges, $a$ origin vertex, $z$ destination vertex, $L$ shortest distance.execution trace
execution animation
Solve games/puzzles, e.g., missionaries and cannibals, tic-tac-toe.
Maze generation.
Travelling salesman.
A directed graph defines a binary relation on a set and vice versa.
Properties are easier to see on a graph and closures easier to compute.
Traversal: list all nodes only once.
Depth-first: go as far as possible, come back to last choice, take another path. Result: $ABDFECG$.
Breadth-first: all 1 step, all 2 steps, all 3 steps ... Result: $ABCEDFG$.
animations.
Prim (greedy): add cheapest edge from tree so far to outside nodes. animation.
Kruskal: add cheapest edge to bridge disconnected subtrees. animation (disregard the code).