Graphs occur everywhere--not surprisingly, since any binary relation determines a graph. Graphs are often represented pictorially, for example Figures 12.1 and 12.2.
Both graphs consist of a collection of nodes connected by various arcs. (A node is often called a vertex and an arc is often called an edge.) In Figure 12.1, the arcs have no particular direction. This is called an undirected graph. The arcs have arrows on them in Figure 12.2. This represents a directed graph.
Information may be attached to the nodes or arcs of a graph, or to both as in the case of Figure 12.2. In the latter case, the nodes are labelled and the arcs are weighted. Numerical weights are sometimes referred to as costs, especially if they are positive. For example, Figure 12.2 might represent a network of airports, with the weights representing costs of direct flights between them, in terms of time or money.
Graphs may possess or lack various topological properties. For
example, Figure 12.1 is said to be an acyclic
graph because it possesses no closed paths (cycles). Graphs are said
to be connected if there is a (directed) path connecting any
two nodes.
We shall not pursue these matters further except to note that, in
Figure 12.2, you can get from any node in the graph to
, but
you cannot get from
to anywhere else.
Note that there is at most one directed arc between any two nodes in Figure 12.2. In general we shall allow there to be several arcs in either direction and they can have different weights. For example, there are often several direct flights between two cities in either direction, sometimes with different costs. This is sometimes called a multigraph.