COMP201 SI Worksheet 11 - Suggested Solns
COMP201 SI Worksheet 11 - Suggested Solns
Question One
1. Suppose you are given a complete graph with 5 vertices. How many edges are present in the
graph?
10 Edges n(n-1)/2
2. Given the following edge array, can we conclude that the resultant graph is simple? Edge Array:
{{0, 4}, {4, 0}, {1, 2], {1, 3}, {2, 4}, {3, 1}, {3, 3}, {3, 4}, {4, 0}}.
Question Two
You friend has created a new social media application called “Howzit”. The app has a similar structure to
that of Twitter and Instagram in the sense that you have followers and a following. The app is currently
in beta testing where there are currently only 7 users. Given the social graph below, where an edge from
a user u1 to u2 indicates that u1 follows u2, answer the questions that follow. The subscript i from ui
indicates the vertices number.
1. State where the graph is simple, complete or incomplete. Also state whether the graph is
directed, undirected, weighted or unweighted. Provide a reason for your answer.
It is a Simple Graph. The graph is not fully connected to make it a connected graph. The graph is also
directed an unweighted. Directed because only some vertices that are bidirectionally connected to
another Vertice.
2. For the graph above, construct the edge array representation of the graph.
{4, 7},
{5, 4},
U1 U2 U3 U4 U5 U6 U7
U1 0 0 1 0 1 0 1
U2 1 0 1 0 0 0 0
U3 0 1 0 0 0 0 0
U4 0 0 0 0 0 0 1
U5 0 0 0 1 0 0 0
U6 0 0 0 1 0 0 1
U7 1 0 0 1 0 0 0
Question Three
Given the adjacency matrix below, answer the questions that follow. Assume that each edge has a
length of 1.
A B C D E F G H
A 0 1 1 0 0 0 0 0
B 1 0 0 1 1 0 0 0
C 1 0 0 1 0 0 0 1
D 0 1 1 0 1 1 0 0
E 0 1 0 1 0 1 1 0
F 0 0 0 1 1 0 0 0
G 0 0 0 0 1 0 0 1
H 0 0 1 0 0 0 1 0
2. Suppose I need to go from city C to city G. Provide two paths to conduct my travels with a
minimum path length of 4.
Two non-optimal paths are [C -> A -> B -> E -> G] and [C -> A -> B -> D -> E -> G]. Many more
available
3. Suppose I need to conduct my travels from (1) in minimum time. Which algorithm can I use to
find the shortest path to my destination? What is then the best path to my destination?