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

Added on - 16 Sep 2019

  • 2

    pages

  • 599

    words

  • 59

    views

  • 0

    downloads

Showing pages 1 to 1 of 2 pages
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
desklib-logo
You’re reading a preview
card-image

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Unlock This Document