i 39 m writing code in c for a weighted graph the graph is undirected i 39 ve includ 5188496
I'm writing code in C++ for a weighted graph. The graph is undirected. I've included instructions and a text file with all the edges and vertices. I need to implement this text file as per the instructions. The edges have all the weights associated. The graph is based off the children's TV show Thomas the Tank Engine.
The Great Northern Railway
The show and book series Thomas and Friends is based upon a fictional railroad on the fictional Isle of Sodor. For this assignment, you will write a program that will analyze various changes to the rail map using the graph algorithms we have discussed in class.
The Earl wishes to make the GNR traversable in a loop for tourism. To facilitate this, he will add routes between:
Arlesdale Road and Peel Godred (a distance of 5),
Culdee Feel Summit and Lakeside (a distance of 3),
Ffarquhar and Wellsworth (a distance of 4),
Bendham and Wellsworth (Distance of 4), and
Norramby and Vicarstown (Distance of 4).
You are to, using the data from the input file(s), answer these questions:
· Given that the trainyard is in Tidmouth, Sir Topham Hatt wants to know how the travel distance from Tidmouth to all the station changes. What are these routes, and did any get shorter with the new additions?
· Is an Euler Circuit possible with the new routes?
· Sir Hatt may decide that these new tracks are too expensive to maintain. What is the minimum amount of rail needed (in distance) for the original and new networks and which connections are different?
The data is in the soror.txt file. Each line stores the source, destination, and distance between stations, e.g.:
The string class' find and substr function can be useful in extracting the three sub-parts of the string; there are other ways.
Be sure to put a copy of the file in your code's working directory to load properly.
When implementing this assignment, there are three major tasks:
1. Writing a data file loader. We have used several file opening bit of code before; you can use those as a base and refer to the text and online documentation for more information.
2. Write a graph class. It should represent an undirected graph; you can choose whether you use an adjacency matrix, adjacency list, or other. You'll need methods for adding nodes/edges, listing the nodes, finding an edge weight, and getting a node's neighbors at the minimum.
3. Write the algorithms to answer the questions above.
Text File: Vertices and Edges
Crovan's Gate:Kellsthorpe Road:4
Kellsthorpe Road:Rolf's Castle:2
Rolf's Castle:Kirk Ronan:2
Skarloey Road:Devil's Back:1
Devil's Back:Culdee Fell Summit:1
Kirk Machan:Peel Godred:2
Arlesburgh West:Arlesburgh Bridge St.:1
Arlesburgh Bridge St.:Ffaquhar Road:1