Graphs and Networks: Vertices, Edges
Graphs and Networks: Vertices, Edges
Vertices, edges
In graph theory, the term 'graph' means a set of vertices, or nodes, connected by edges. or arcs.
Graphs may have loops that connect a vertex to itself. They rnay also have multiple edges joining any two vertices.
A loop
A graph is made up of subgraphs. A subgraph is a graph in its own right and may consist of a vertex, two vertices and an edge, or many vertices and edges.
u
y
Multiple edges
The actual positions of the vertices and the shapes of the edges do not matter.
! !
Two graphs are equivalent, or isomorphic, if one can be transformed into the other without breaking any edges.
You will not be examined on isomorphic graphs but it is useful to know the terminology.
We need to topologically transform the graphs so that they look the same.
Step I : Drop P down to ? i t betweerr C). R, S and 7: We could relabel the second graph so that P becomes C, Q becomes A, R becomes B. S becomes E. and T becomes D
Step 2 : Pull edge QT to the top to make the two graphs look the kame.
The two graphs are the same. C and P are connected to each of the other four vertices, and every other vertex is connected to three other vertices.
If a graph does not contajn loops or multiple edges, it is called a simple graph.
A connected graph is one where it is possible to reach any vertex from any other vertex, directly or indirectly.
A graph that is not connected can be split into two or more disconnected subgraphs. A graph that is both simple and connected is called a simply connected graph.
In a directed graph, or digraph, some of the edges have a specific direction assigned (like a one-way street). A directed edge will be marked with an arrow to show its direction.
& 6 ~ ~ % ~ i r -+
]I'R~~Is
A planar graph is one that can be drawn so that the edges do not cross over one another.
The graph on the left is planar becallre it can be transformed and redrawn as shown in the graph on the right.
A
C
---- - You will not be examined on planar graphs hut it is useful to know the tern~inology
The vertices of a bipartite graph can be split into two sets so that each edge joins a vertex from one set to a vertex from the other set: no edge joins two vertices which are in the same set. For example:
A complete graph of n vertices, K,,, is a simply connected graph where each vertex is connected to every other vertex by only one edge.
I
i
I
A complete bipartite graph K,,, ,, is a simple bipartite graph with two sets of vertices, one of size rn and the other of size n, in which every pair of vertices with one from each set are joined by an edge.
I/
Kg
Alternative for KJ
SKILLS CHECK
2A: Graphs
1 Draw a diagram to show a connected graph with four vertices and five edges
3 The graph K, has many subgraphs, several of which are isomorphic to one another.
There are 10 non-isomorphic subgraphs (8 proper subgraphs. the subgraph with n o edges and the subgraph that is the whole of K,). Draw diagrams to illustrate the eight different proper subgraph types.
a By relabelling the second graph, show that the two graphs are isonlorphic.
b By redrawing the first graph, show that the graphs are planar.
6 a How many vertices and how many edges does the graph K,, have'?
b How many vertices and hou many edges does the graph K,, ,, have'?
c How many vertices and how many edges does the graph K,,, ,, have?
7 Draw an example of an undirected graph that has 4 vertices and 8 edges. Explain why there is n o simple graph that fit, this description.
8 Edges are removed from the graph k'j to make a set of subgraphs that are not connected to one
another.
a What is the maximum number of edges that remain if there are two subgraphs, one connecting
two vertices and one connecting three vertices?
b What is the maximum number of edges that remain if there are two subgraphs, one connecting four vertices and the other consisting of a single vertex'?
c What is the maximum number of edges that remain if there are three subgraphs?
Adjacency matrices
Instead of a diagram, we may be given the information about which vertices are connected in an adjacency matrix. In an adjacency matrix: an entry of '-' or '0' means there is no edge directly joining the two vertices an entry of ' 1' means that there is one edge that directly joins the two vertices an entry of '2' means that there are two different edges that directly join the two vertices. and so on. Graphs with identical adjacency matrices are isomorphic.
Transforming graphs into matrices allows u s to store the infor,nation in a computer,
Example 2.4 Represent the following graphs as adjacency matrices and hence show that they are isomorphic.
To
Step I : Make a tablc with
rows and columns labcllccl
Ti?
D E
A A
From
From
D
E
Step 2 : For each \.crtex recol.d the rlumher ol'cdfes Ieaciing to each ol' the othcr \,e~.tices.
AIBIC A From C I
D l 1 l -
t
because you can go either way around the loop.
l 1
-
l l
B 1 - 1 - - 1 1 1 1 -
From
D
E
Step .?: Keorclcr the row5 and columns o f rhc wcond ~ n a t r i x that it lool\s the so samc ;I\ !he firnt. This shows t h ~ i thc t h o gl.ilphs t Lue thc samc.
1 2 1 1
From
e sum across the rows o the tables we can see that A. B, E, (2. R, S and T have three edges coming from them and, C and Peach have 4 edges and 11 and T have 5 edges.
SKILLS CHECK
A B C
,.
J K L M
b Deduce whether either of the first two graphs is isomorphic to the third.
The degree of a vertex is the number of edges meeting at that vertex If the number of edges is even, the vertex is called an even vertex. If the number of edges is odd, the vertex is called an odd vertex.
A trail is a sequence of edges such that the end vertex of one edge is the start vertex of the next.
A path is a trail with the additional restriction that no vertex is passed through more than once.
A cycle is a path to which an extra edge has been added to join the final vertex back to the initial vertex.
Travelling Salesperson problem in Chapter 7, the word tour is used to describe a closed trail.
Example 2.5 For the graph shown on the right, give an example of:
a a trail
b a path
a a cycle.
Step 1 : 1,ook fol- a secluencc ofcdyes whcrc nonc of the edgcs are repeated. Step 2 : I.ook fol- ;I lr~rii with no repeulccl vertices. Step -3: Looh for a path ancl
a An example of a trail is A - B - D F - B - C.
-
Vertex B I \ pa\\ed through Im8lc.e none of the edges are but repeated.
b An example of a path is A - B - D - F.
c An example of a cycle is A - B
-
D -F-A.
add an edge to makc the cnd point thc same as the start.
SKILLS CHECK
c Find the sum of the degrees of all the vertices and the number
of edges in the graph.
a A-B-C-D-E-F-G-A
b A-B-C-D-E-G-F
c A-B-C-D-E-C-A
4 Draw an example of a connected graph with four vertices on which there are no cycles.
5 Draw a graph that has two vertices of degree 3 and two vertices of degree 1
6 a Draw the graph represented by the following adjacency matrix.
b Write down an example of a path that passes through all four vertices on the graph.
c Write down an example of a cycle that passes through all four vertices on the graph.
7 a Show that it is not possible to have an undirected graph with four vertices, one of degree 2 and three of degree 3.
b Draw a directed graph that has four vertices. one of degree 2 and three of degree 3.
8 Draw a graph that has four vertices on which there is a trail through all four vertices but there is no
path through all four vertices.
An Eulerian graph has a closed trail that contains e;iery edge exactly once. A semi-Eulerian graph has a trail that is not closed but which contains every edge exactly once.
The easiest way to check whether a graph is Eulerian, semi-Eulerian or neither is to count the number of vertices of odd degree. An Eulerian graph has no vertices of odd degree and a semi-Eulel-ian graph has exactly two vertices of odd degree.
Example 2.6 a Is the graph shown on the right Eulerian, seini-Eulerian or neither?
b What happens if an extra edge is added joining C to E'?
Step I Count the degrcc ol each \ ertex Step 2 : Count the number of odd vertices. Step.?: Arnend the clcgrces of the vertices.
b With the extra edge, C and E become odd and the new graph is semi-Eulerian.
Any semi-Eulerian trail on this graph must have C and E as its initial and final vertices.
A Hamiltonian cycle is a cycle that passes through every vertex exactly once and returns to the starting point.
A Harniltonian cycle does not have to pass through every edge once.
Harniltonian cycles are explored further in the Travelling Salesperson problem in Chapter 7.
SKILLS CHECK
1 A connected graph G has 17 vertices. State the minimum number of edges in a Hamiltonian cycle. 2 A connected graph G has six vertices. The degrees of the vertices are 2, 3,4. 5 , 6 and d.
a The graph is semi-Eulerian. What can you say about the value of d?
b The graph has 12 edges. What can you now say about the value of d ? 3 A graph G is shown on the right.
B E
b Write down the degrees of the vertices and explain how this shows you that the graph is Eulerian.
c Write down an Eulerian trail for the graph.
5 a Explain why A - B - D - C -A
b Write down a I-Iamiltonian cycle for the graph. 6 a Is the graph K, Eulerian, semi-Eulerian or neither? Explain how you know. b What is the least number of edges that need to be removed from the graph K4 to make it Eulerian?
7 Ignoring the starting point and the direction of travel, how many distinct Hamiltonian cycles are there on the graph K,?
8 A simply connected Eulerian graph connects five vertices using six edges. Does a Harniltonian
cycle exist on such a graph?
An edge weight is a numerical value given to an edge that may represent a distance, a journey time, a profit or a cost, for example. A network is a graph with weighted edges.
mD3
The diagram shows edge weights that represent the distance fro111 one vertex to another.
7
E
The diagram could equally represent the cost to get from one city to the next t h e matrix would then be called a cost matrix.
The distance matrix for the network represents the same infonnation as the diagram but in matrix form.
A 4 1 1 -
B 4 5 7
C 1 5 1 4
D 1 1 3
E 7 4 3 -
In a distance matrix the numbers represent the edge weights and 0 or '-' means that there is no edge directly joining these two vertices.
B 3 4 2 -
C 4 5
D E 2 1 2 - 5 - 3 3 -
Step 2: I l r : ~ u ;in cdgc connec[ln; p:rlrs \r here a value i s \vri[tcn and write the ~ e i ; h t o n tlic cdfc.
SKILLS CHECK
o m
5 Calculate the length of an Eulerian trail on the network represented by the distance matrix
A B C D
6 Annie lives 2 miles from each of Bob, Carl and Dawn. Bob lives 1 mile from Dawn, and Carl lives 3
miles from Dawn.
B x
C 12
D 15
8 The matrix below shows the direct travel times. in minutes, between five underground stations.
The time for a journey is found by adding the direct travel times for each leg of the journey and then adding an extra 2 minutes for each station passed through, excluding the start and finish.
a What is the journey time for a passenger who gets on at P and travels to T via Q?
b What is the journey time for the quickest Hamiltonian cycle on the network?
Trees.
A tree is a single, simple graph on which there are no cycles. The following are all examples of trees.
Any graph has a spanning tree (a subgraph that connects all the vertices on the original graph, and is alqo a tree). A spanning tree on a graph with 11 vertices will have 11 - 1 edges.
Original graph
A minimum spanning tree is a spanning tree of minimum total weight on a network. It is a spanning tree for which the sum of the edge weights is as small as possible. A minimum spanning tree can also be called a minimum connector
SKILLS CHECK
2F: Trees
1 A connected graph G has 11 vertices. State the number of edges on a spanning tree on G.
2 A network has four vertices and four edges. The edge weights are 2. 5, 10 and 20. The minimum spanning tree has weight 32. Draw a diagram to show a network that fits this description.
3 There are only three non-isomorphic spanning trees that can be drawn on five vertices.
Draw diagrams to show all three types.
4 a A spanning tree includes a vertex of order 5, explain why it must have at least five vertices of order 1.
b Draw a spanning tree that includes a vertex of order 5 and has exactly six vertices of order 1 .
6 A network is represented by the matrix below. The minimum spanning tree has weight 35. What can
you conclude about the value of s? A B C D
b What is the length of the shorieht closed trail through every vertex of a tree?
8 A tree has vertices of degree 1, 1, 1, 2 , 3 . n.
1 a A connected graph has four vertices. State the number of edges in t11e graph's
minimum spanning tree.
b A graph has n vertices. 'l'he graph is complete, i.e. each vertex is joincd to every other vertex by exactly onc cdge. i Slate the number of cdges in the graph's minimum \panning tree. ii Deterrninc thc number of Hamiltonian cycle\ in the graph.
c A connected graph has Sour vet-tices and has arc lengths of
2 'The following question refers to the thrcc graphs: Graph 1, Graph 2 and Graph 3.
Graph 1 Graph 2 Graph 3
For each of the graphs explain whether or not the graph is Eulerian.
3 A _graph G has five vertices.
a i Given that G is connected, state thc number of arcs on a minimum spanning tree. ii Given that G is Eulerian with all vertices having the same degree d, state the minimum value of d. iii Given that G has a Hamiltonian cycle, state the number of edges in wch a cycle. b Given that G has all the properties mentioned in part a, draw a possible graph G.
[AQA(A) Jan 20:
7 A graph G is shown.
I53
A B C - 1 1 1 - 1 - 1 1 1 - 1 -
c For this graph. calculate the number of spanning trees that use neither of the edges AC and AD.
explaining your reasoning.