BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

C++代写 | CS515 Assignment 12

C++代写 | CS515 Assignment 12

这个作业是用C++实现一个程序来模拟网络
CS515
Assignment 12

In this assignment, you are asked to implement a program to simulate a network. The program first
constructs a graph from an input file. The file name will be the one and only command-line argument
passed to the program. The input file stores a weighted, undirected, connected graph. The file contains
entries formatted as follows:
<name1> <name2> <weight>
Each 3-tuple denotes a link between the nodes <name1> and <name2> that has a weight of <weight>.
The name of the node is an ASCII string (the label may be longer than one character) and the weight is a
non-negative integer value.
The starter code contains an executable that can be run as
%mynetwork data0
to demonstrate a sample run with the sample graph in Figures 1 and 2.
The program will read from the file whose name is passed as a command line
argument, and then construct the graph and its minimal spanning tree. Next, the
user is presented a prompt to query the graph from a starting node (which is the
first node of the first tuple of the input file). The starting node is displayed at the
prompt as:
<start>#
The user can then work with simulated network commands ping, ssh, and exit
interactively from the keyboard. When the user issues the ping command to
communicate to a target node, the program uses the MST to generate a stack of
nodes that construct the path from the start node to the target node (shown➔).
The ssh command allows the user to change the current node. For example, by
calling ssh to B at current node A, the current node is changed to B. Then the ping
commands that follow will print out paths using B as the new starting node.
The user may continue to move to other nodes using ssh, and they are also allowed
to ssh to the same node. The program must keep track of the user’s ssh
history, so they are able to exit from the previous ssh using the exit
command. For example, suppose they have moved from A to B and then
from B to E. The first exit disconnects from E and returns to B. The second
exit disconnects from B and returns to A (the current run’s starting node),
and the last exit terminates the program.
The program displays an error message if ping or ssh commands are
issued to a non-existing node in the graph (as illustrated below)
You may assume that the input file and commands issued at the program prompt are all in proper valid
formats.
Requirements:
• The MST must be built using Kruskal’s minimal spanning tree algorithm.
• You need to implement your own disjoint set data structure (See Lab 10) that will be used in
Kruskal’s algorithm.
<A># ping Z
Cannot find node. Available nodes are:
A
B
C
D
E
F
G
<A># ssh Z
Cannot find node. Available nodes are:
A
B
C
D
E
F
G
<A># ping B
From: A
To: B
<A># ping F
From: A
To: B
To: D
To: E
To: F
<A># ping E
From: A
To: B
To: D
To: E
<A># ssh B
<B># ping E
From: B
To: D
To: E
<B># ssh E
<E># ping A
From: E
To: D
To: B
To: A
<E># exit
<B># exit
<A># exit
% (program ends)

bestdaixie