We are introduced to definitions of graphs, various kinds of graphs, characteristic features of graphs, and even a few theorems about graphs (for example, we learn when two graphs are the same, or isomorphic, even when they look strikingly different).
We then take a look at planar graphs (in particular at Euler's formula), and computer representations of graphs (adjacency matrices, adjacency lists).
A graph is defined loosely as a set of nodes, and a set of arcs which connect some of the nodes.
More formally, we have the following
Definition: a graph is an ordered triple (N,A,g) where
x and y are the endpoints of the arc.
g is a function
and
.
Example: Practice #1, p. 342/404.
Definition: a directed graph is an ordered triple (N,A,g) where
so g is a function
and
.
Example: Exercise #1, p. 361/423.
Take a moment to draw a graph - that is an object consistent with the above definition(s). Using the graph terminology handout to classify your graph. In particular the vocabulary we want to focus on is as follows:
Example: Exercise #2, p. 362/423.
By
we will understand the simple, complete graph with n nodes.
Example: Exercise #5a, p. 362:/423 Draw
.
A bipartite complete graph
is a graph of N nodes which break
into two groups,
and
, of size m and n respectively, with the
property that two nodes x and y are adjacent
and
.
Example: Exercise #5b, p. 362/423: Draw
.
The idea of isomorphism is that two structures can be ``morphed'' into each other (they are in some sense identical, up to labelling). Our objective, in general, is to figure out the ``morphism'' (isomorphism - same form!).
Example: Look at Figure 5.17, p. 350/411: can you morph the two graphs together?
Definition: Two graphs
and
are
isomorphic if there are bijections (one-to-one and onto mappings)
and
such that for each arc
,
(replace braces by parentheses for a directed graph).
Example: Practice #7, p. 350/412. If you managed to morph the two
graphs in Figure 5.17, then you should be able to ``see'' the rest of function
.
Theorem: Two simple graphs
and
are
isomorphic if there is a bijection
such that for any nodes
and
of
,
and
are adjacent
and
are adjacent.
Example: Exercise #11/15, p. 363/425.
Here are some tests for determining when two graphs are not isomorphic:
Example: Exercise #8/12, p. 362/425.
A planar graph is one which can be drawn in two-dimensions so that its arcs intersect only in nodes. ``Designers of integrated circuits want all components in one layer of a chip to form a planar graph so that no connections cross.'' (p. 352/413)
Example: Revisit #11/15, p. 363/425.
Euler's Formula for simple, connected planar graphs states that
where n is the number of nodes, a is the number of arcs, and r is the number of regions (including the infinite region surrounding the graph).
Think ``ran to'' to remember the formula....
Check out the author's proof of the theorem (p. 353/414): Hey! What's induction doing in here? Euler's formula is proven by induction, on a, the number of arcs, and a consideration of cases (node of degree 1; no node of degree 1).
Note: about Euler (Born: 15 April 1707 in Basel, Switzerland Died: 18 Sept 1783 in St Petersburg, Russia). He was so prolific that his work is still being compiled. He went blind in his old age, and became even more prolific! He was an incredible calculating machine.
Example: Revisit #11/15, p. 363/425., for a check.
The following theorem provides some estimates on the relationship between the number of arcs and nodes that a planar graph may possess:
Theorem: For a simple, connected, planar graph with n nodes and a arcs,
From this theorem we can deduce that
is not planar, since it has 5 nodes,
and 10 arcs, and
.
Also from this theorem we can deduce that
is not planar, since it has
6 nodes, and 9 arcs, and no cycles of length 3:
.
Example: Exercise #22/26, p. 365/427.
We want to examine two different representations of graphs by a computer:
A matrix is basically a spreadsheet: a rectangular data set of numbers indexed by rows and columns.
An adjacency matrix for a graph with N nodes is of size N by N,
where the rows and columns of the matrix represent the vertices. If the graph
is undirected, then the element
of the matrix is non-zero
nodes
i and j are adjacent; if directed, then the element
of the matrix
is non-zero
there is an arc from node i to node j.
In our textbook, the element of the matrix
, the number of arcs
meeting the criteria above.
Example: Practice #16, p. 358/419.
For an undirected graph the adjacency matrix is symmetric (which means that we can reduce storage by about half); for a directed graph, the matrix may well be unsymmetric.
Let's look at a nice web page, with an example of a directed graph .
Example: Exercise #33/37, p. 366/428.
An adjacency list might be a better storage method for graphs with relatively few arcs: we effectively store only the non-zero entries of the adjacency matrix, in a linked list:
Example: Exercise #48/52, p. 367/429.
The redundancy in drawing the adjacency list for an undirected graph is evident. This is eliminated for a directed graph:
Example: Exercise #57/61, p. 367/430.