CSCI 2824 Lecture 29: Graph Theory (Basics)In this lecture, we will study graphs and some very basic properties of graphs. We will conclude by studying the concept of Eulerian tours. Directed GraphsWe have already encountered graphs before when we studied relations. We viewed graphs as ways of picturing relations over sets. Definition: Directed Graphs
A directed graph
We draw a graph Example-1Take ![]() Example-2Take ![]() The edge Assumption
In the study of graphs, will assume that any graph we look at does not have self loops. Most of the results discussed below applies to graphs without self-loops. Why Study Graphs?Graphs are useful in a variety of situations. Graph models are really common representations of networks (computer networks, social networks, protein networks,…). It is very useful to model a variety of entities as graphs and study their structure:
Undirected GraphsSo far, we have studied directed graphs, which are just representations of relations over finite sets (assume that there are no self-loops). An undirected graph is a special kind of directed graph that occurs when the edge relation is symmetric. Definition: Undirected Graphs
An undirected graph
As a result, we draw an undirected graph by not drawing placing any arrows on the edges. Edges are simply straight-lines. Alternatively, we could have represented each edge by a double arrow, one in each direction or two sets of arrows. These are all equivalent. Example-1Consider the undirected graph ![]() Example-2Take ![]() Once again, this graph has self loops. But we will silently assume, henceforth, that there are no self-loops. Representing GraphsThere are two ways of representing a graph inside a computer: adjacency list or a adjacency matrix. You should already be aware of adjacency list and matrix representations of graphs from your data-structures class (please email me if you are not). We will not go into these concepts here. Degrees and Degree SequencesIn/Out DegreeLet The set of incoming edges of a vertex In-Degree
In-Degree For any vertex Similarly, we can define outgoing edges for a given vertex Out-Degree
For any vertex Note For a undirected graph, the set of incoming edges is the same as the set of out-going edges for any vertex Degree
The degree of a vertex Note that the concepts of in-degree and out-degree coincide with that of degree for an undirected graph. Degree SequencesLet us take an undirected graph Example-1Consider the undirected graph ![]()
The degree sequence is Example-2Here is a graph with degree sequence ![]() Example-3Can you construct a graph with a degree sequence It needs to have three vertices Properties of Degree SequencesGiven a undirected graph Example-1Can there be an undirected graph (no self-loops allowed) with degree sequence Answer
There can be no such graph. Let us try to construct such a graph. How many nodes does it need to
have? from the degree sequence, we know that it has Sum of Degree SequenceFor an undirected graph In other words, let Proof
By summing up the degree of each vertex, we are counting all edges
that are incident on that vertex. In this summation, therefore each
edge As a consequence, the summation of a degree sequence must be even. ExampleIs it possible to have a graph (no self-loops allowed, remember) with
the following degree sequence Answer
Answer is no since the sum of the degree sequence is Degree Sequence and Pigeon Hole PrincipleLet
Proof
The proof is simple application of the pigeon-hole principle. In In/Out degress for directed GraphsFor a directed graph In other words, the sum of in-degrees of each vertex coincided with the sum of out-degrees, both of which equal the number of edges in the graph. This is because, every edge is incoming to exactly one node and
outgoing to exactly one node. Therefore summing up all the in-degrees,
counts very edge WalkGiven a graph
A walk has to respect the edge direction. In other words, if we go
from vertex Example-1Take the graph: ![]() Here is a walk: Here is another example of a walk: Here is an example of a sequence that is not a walk: There is no edge from Example-2Take the graph: ![]() Here are some walks
PathsA path in a graph is a walk that does not repeat any vertices. The length of a path is the number of edges traversed by the path and one less than the number of vertices traversed. Consider, again, the graph below: ![]() Examples of paths include:
Non-examples of paths include:
Eulerian TourRead about the Koenigsberg bridge problem here: Seven Bridges of Koenigsberg. Here is the map of Koenigsberg in Germany where the famous mathematician Leonard Euler lived: ![]() The green ovals show the bridges. Question is can we take a tour of each of the bridges:
We can ask the same question on the following graph which represents the topology ![]() ![]() ![]() Is the connection between the original “topology” of the bridges and graphs clear? If so, then the problem can be stated as: Let us “walk” the graph starting from any vertex and traversing any edge that takes us to a neighbouring vertex and so on, such that
Eulerian TourDefinition:Eulerian Tour
An Eulerian tour is a special walk of the graph with the following conditions:
Example-1Does this graph have an Eulerian Tour: ![]() Yes, here is a tour: We started from Example-2What about this graph? ![]() It does not have a tour. This is the graph, we derived from the Konigsberg bridge problem. Turns out that we cannot have an Eulerian tour here.
To see this, let us focus on the vertex labelled
Theorem
An undirected, connected graph Since the graph of Konigsberg bridge problem has vertices |