Graphs

Graphs are, basically, relations, with a little bit of extra syntax that lets you express interesting properties of connections between nodes. Strictly speaking, a graph is an ordered pair G = (V,E), where V is a set of vertices, (like the set "A" we've talked about for the last several days), and E is a set of edges between vertices (where is a relation on A). For reasons that are not clear to me, a graph G is often written in a way that looks like G is a function of V,E.. the following notation is the way you define a graph G:

G(V,E)
with the constraint that V is a set and E is a subset of VxV.

Graphs are perhaps the most important data structure in computer science. They are "simple" in the sense that they have a very well defined structure (nodes and edges, that's it). But they are also "expressive" in that these nodes and edges can represent an amazingly large collection of problems that are of interest.

So, the diagrams of relations from a set to itself are graphs. When we have a relation defined from one set to another, we can define a "bipartite" graph as: G( V = A union B, E = A x B), where A and B are non-overlapping, and all the edges going between a node in set A and a node in set B.

There are a small number of important properties about graphs that come up in a large number of problems:

  1. Paths: A path is a list of vertices v_0 ... v_k where every consectutive pair of vertices is in the edges set of the graph. (how would you write this formally?)
  2. An undirected graph is a graph whose edge set E is symmetric (so that any vertices that are connected are connected both ways).
  3. A connected component is a collection of nodes that are mutually reachable.
  4. A "tree" is a connected, acyclic graph.
  5. Hamiltonian and Euler Paths. Hard to tell if graph has hamiltonian path. Easy (?) to tell if there is an euler path, pretty easy to construct it.
  6. Many problems can be expressed by adding a function w(e): E -> R that is a "weight" or "distance" of an edge, or a function c(v): C -> R that is a "cost" or "price" of a vertex.