Ask a question from expert

Ask now

Create a graph class that stores an array of nodes, representing

2 Pages599 Words212 Views
   

Added on  2019-09-16

Create a graph class that stores an array of nodes, representing

   Added on 2019-09-16

BookmarkShareRelated Documents
CPSC 231 Project 07Name _____________Create a graph class that stores an array of nodes, representing a unidirectional(directed) graph. Create a node class that stores a string, and up to 8 edgesconnecting other nodes.Your program will take as input a file containing node names and links. Each line in thefile will contain the name of a node, a node connected to it, and the distance. Namesmay be repeated for additional links. Example:A B 10A D 5A E 10D C 4D F 4C B 8C F 3F C 2F E 8Use the following data files to test your program:https://www.msu.edu/~bowmanm/231/Project07.zipThis file contains: Project07a.txt, Project07b.txt, Project07c.txtThe graph class should have the following data elements:MapAn array of nodesNNumber of nodes in graphThe graph class should have the following functions:ConstructorInitialize the empty graphInsertInsert an edge into the graph. Takes three parameters, a value forthe source node, a value for the target node, and the weight of theedge. If either of the values do not exist, add them to the node list.DepthDisplay the values of a depth-first search. Takes two parameters,the output stream, and the value of where to start the search.BreadthDisplay the values of a breadth-first search. Takes twoparameters, the output stream, and the value of where to start thesearch.FindReturn true/false if the string is found in the treeThe node class should have the following data elements:ValueStored valueVisitBoolean indicator shows if node has been visitedEdgeArray of pointers to other nodesDistanceArray of edge weights
Create a graph class that stores an array of nodes, representing_1

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Solving a Color Maze using DFS
|7
|1042
|184

Programming, Algorithms and Data Structure: Weekly Tasks and Exercises
|2
|501
|348

COP3538 Assignment Java Projects
|5
|1636
|280