XMUM.OAA Adjacent vertex


XMUM.OAA - 100/2/8-V3.0 Page | 3
F. Task(s)
Consider the graph in Figure 1, each vertex is representing a place to visit and each edge is 
representing the cost from/to the Adjacent vertex.
Figure 1 : The graph
XMUM.OAA - 100/2/8-V3.0 Page | 4
I. Coding:
1. Represent the graph using adjacency matrix.
2. Print the sequence the visited places using BFS and DFS (following the cost and 
start with any place selected by the user).
3. Print the sequence of DFS user preference and BFS user preference where, the 
sequence of visited places starting by any place selected by the user and the next 
place shall be based on the BDF or DFS traversal. If there is more than one options, 
ask the user to select one of them then continue until there is no more segregation. 
Do this process using DFS and BFS separately. 
So, your welcome screen shall print matrix representation for the graph, then asked the 
user to select between DFS Basic or BFS Basic or DFS user preference or BFS user 
preference. Then ask the user to select the start point. If the user chooses the Basic version, 
show the traversal sequence starting from the start point (selected by the user) based on 
the cost. If the user chooses the user preference version, you are going to show suggestion 
what is the next place to visit (or to enqueue) and its cost. If there is more than one 
suggestion at the same time, allow the user to select one of the possible suggestions and 
continue until all the places has been visited and there is no more suggestion. At the end, 
print the traversal order sequence based on the selected method. 
II. Report:
In your report, show the following:
1- Show screenshot for the output of your matrix representation of the graph. 
2- Show screenshots for two complete examples, one using DFS (User preference) and 
another one using BFS (User preference). 
XMUM.OAA - 100/2/8-V3.0 Page | 5
Example: 
(after print the matrix representation)
Which method you want to use: 
1- DFS sequence (Basic)
2- BFS sequence (Basic)
3- DFS sequence (User preference) 
4- BFS sequence (User preference) 
User choose: 3
Please Select your start point: 
User choose: KLIA
Please what place you want to visit after KLIA: 
1- KLCC (12)
2- Melaka (50)
3- TBS (10)
User choose: 1
Output: 
Based on DFS(User preference) , after visiting KLCC you may visit next: 
1- TBS (5)
2- Batu Caves (30)
3- Aquaria KLCC(2)
User input: 2
Output: after visiting Batu Caves you may visit next:
1- Genting Highland (15)
2- Colmar Malaysia (10)
…. Until visiting all the places and there is no more suggestion 
Final Output: 
The sequence of visited places based on DFS and your preference is:
KLIA, KLCC, Batu Caves, ……..
XMUM.OAA - 100/2/8-V3.0 Page | 6

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值