Graphs G = (V, E) V are the vertices; E are the edges. Edges are of the form (v, w), where v, w V. ordered pair: directed graph or digraph unordered pair: undirected graph weighted graph: A weight or cost can be associated with each edge.
Graph Examples v9 v8 v10 v6 v7 v1 v3 v4 v2 v5 4 D F 1 8 10 4 A C 3 E G B
Terminology w is adjacent to v iff (v, w) E. edge e = (v,w) is incident to vertex v e is also incident to vertex w degree of a vertex: number of incident edges. path: sequence of vertices and edges connected together. length of a path: number of edges in the path. simple path: all vertices are distinct.
Representation adjacency matrix: (|V|2) space. adjacency list (sparse graphs): 1 2 3 4 2 3 4 3 1 2 1 2 3 4