Definitions: Graph, Vertices, Edges
Definitions: Graph, Vertices, Edges
Definitions: Graph, Vertices, Edges
Edges:
1. Each edge is defined by a pair of vertices
2. An edge connects the vertices that define it
3. In some cases, the vertices can be the same
o Vertices:
1. Vertices also called nodes
2. Denote vertices with labels
o Representation:
1. Represent vertices with circles, perhaps containing a label
2. Represent edges with lines between circles
o Example:
1. V = {A,B,C,D}
2. E = {(A,B),(A,C),(A,D),(B,D),(C,D)}
Motivation
Examples:
o Cities with distances between
o Roads with distances between intersection points
o Course prerequisites
o Network
o Social networks
o Program call graph and variable dependency graph
Graph Classifications
Undirected Graphs
o
In diagrams, edges have no direction (ie they are not arrows)
o Can traverse edges in either directions
o Actually, an edge is a set of 2 nodes, but for simplicity we write it with parens
Directed Graphs
Subgraph
If graph G=(V, E)
o Then Graph G'=(V',E') is a subgraph of G if V' V and E' E
Degree of a Node
The degree of a node is the number of edges the node is used to define
Examples
A directed graph is strongly connected if every pair of vertices has a path between
them, in both directions
o Adjacency matrix
Adjacency List Representation
Time:
o To visit each node that is adjacent to node u: (degree(u))
o To determine if node u is adjacent to node v: (degree(u))
Time:
o To visit each node that is adjacent to node u: (V)
o To determine if node u is adjacent to node v: (1)
Question 2
Application 1
Travelling salesman problem
As a graph problem
The requirement of returning to the starting city does not change the computational
complexity of the problem, see Hamiltonian path problem.
The generalized traveling salesman problem deals with "states" that have (one or
more) "cities" and the salesman has to visit exactly one "city" from each "state". Also
known as the "traveling politician problem". One application is encountered in ordering a
solution to the cutting stock problem in order to minimise knife changes. Another is
concerned with drilling in semiconductor manufacturing, see e.g. U.S. Patent 7,054,798.
Surprisingly, Behzad and Modarres demonstrated that the generalised traveling salesman
problem can be transformed into a standard traveling salesman problem with the same
number of cities, but a modified distance matrix.
The sequential ordering problem deals with the problem of visiting a set of cities
where precedence relations between the cities exist.
The traveling purchaser problem deals with a purchaser who is charged with
purchasing a set of products. He can purchase these products in several cities, but at
different prices and not all cities offer the same products. The objective is to find a route
between a subset of the cities, which minimizes total cost (travel cost + purchasing cost)
and which enables the purchase of all required products.
Application 2
Knigsberg Bridge Problem
Knigsberg was a city in Russia situated on the Pregel River, which served as the residence of
the dukes of Prussia in the 16th century. Today, the city is named Kaliningrad, and is a major
industrial and commercial centre of western Russia. The river Pregel flowed through the
town, dividing it into four regions, as in the following picture.
In the eighteenth century, seven bridges connected the four regions. Knigsberg people used
to take long walks through town on Sundays. They wondered whether it was possible to start
at one location in the town, travel across all the bridges without crossing any bridge twice and
return to the starting point. This problem was first solved by the prolific Swiss mathematician
Leonhard Euler, who, as a consequence of his solution invented the branch of mathematics
now known as graph theory. Eulers solution consisted of representing the problem by a
graph with the four regions represented by four vertices and the seven bridges by seven
edges as follows:
Graph Theory is now a major tool in mathematical research, electrical engineering, computer
programming and networking, business administration, sociology, economics, marketing, and
communications; the list can go on and on. In particular, many problems can be modelled
with paths formed by traveling along the edges of a certain graph. For instance, problems of
efficiently planning routes for mail delivery, garbage pickup, snow removal, diagnostics in
computer networks, and others, can be solved using models that involve paths in graphs.
Application 3
Explore diffusion mechanism problem
Graph theory is used in sociology for example to measure actors prestige or to explore
diffusion mechanisms. Graph theory is used in biology and conservation efforts where a
vertex represents regions where certain species exist and the edges represent migration path or
movement between the regions. This information is important when looking at breeding
patterns or tracking the spread of disease, parasites and to study the impact of migration that
affect other species. Graph theoretical concepts are widely used in Operations Research. For
example, the traveling salesman problem, the shortest spanning tree in a weighted graph,
obtaining an optimal match of jobs and men and locating the shortest path between two
vertices in a graph.