View Single Post
Join Date: Sep 2008
Posts: 31
Reputation: JustLearning is an unknown quantity at this point 
Solved Threads: 0
JustLearning JustLearning is offline Offline
Light Poster

Re: Graph help please

 
0
  #3
Nov 12th, 2008
Sorry to be so vague but here are my instructions.

I understand what a graph is but I just dont know how to impliment it.

  1. Your main function must perform all of the following tasks.
  2. (1) Declare a string variable and initialize it with the value argv[1].
  3. (2) Invoke the Load function to input graph data from file along with the search start and end vertices.
  4. Since Load may throw an exception, you should use a try-catch pair to trap the exception.
  5. (3) Once the graph loads, use the Graph class Print function to print out the graph
  6. (4) Perform a Depth-First Search using the start and end vertices input from the file by the Load
  7. function. The path, if found, is stored in a queue (whose address is returned by the DFS function) so
  8. use the Queue class Print function to print out the path. If no path is found, a NULL pointer is
  9. returned by the DFS function.
  10. (5) Compute the weight of the path found by DFS and output to monitor.
  11. Your program must also contain appropriate comments in order to receive full credit.
  12. Your goal is to EXACTLY match the output of your program to that of the sample solution.
  13. Fall 2008 CPE212 Project Assignment Project 8
  14. Page 4 of 5
  15. <Project08 Input File Format>
  16. Use the extraction operator for all inputs!!!
  17. First line of file contains an integer specifying the total number of vertices in the graph.
  18. Use this value when you call the constructor to create the graph.
  19. ‘v’  followed by vertex_name (vertex names are always single-word strings)
  20. ‘u’  an UNDIRECTED EDGE followed by vertex1 vertex2 edge_weight
  21. ‘d’  a DIRECTED EDGE followed by source_vertex destination_vertex edge_weight
  22. ‘s‘  name of dfs_start_vertex
  23. ‘e’  name of dfs_end_vertex
  24. Hints:
  25. - Use the extraction operator for all inputs!!!
  26. - An UNDIRECTED EDGE may be simulated by two DIRECTED EDGES going in
  27. opposite directions with the same weights
  28. <Project 8 Graph Class Description>
  29. The Graph class uses an Adjacency List Representation to store the graph information.
  30. Inline functions are not allowed in this course and will result in no credit (0)
  31. [Note: An inline function is a function whose definition appears within the class declaration]
  32. Attribute Name Data Type Purpose
  33. vertices VertexNode* Stores address of dynamically allocated array of VertexNodes
  34. numV int Number of vertices
  35. Function Name Return
  36. Type
  37. Purpose
  38. Graph N/A Constructor that allocates an array of VertexNodes just large
  39. enough to hold incoming graph
  40. DeleteAllEdges void Deallocates all EdgeNodes connected to all vertices
  41. IsEmpty bool Returns true if Graph is empty, false otherwise
  42. IsFull bool Returns true if Graph is full, false otherwise
  43. AddVertex void Adds vertex name V to vertex array
  44. AddEdge void Adds edge from Source to Destination with specified Weight
  45. IndexIs int Scans vertex array to locate named vertex and returns array index
  46. WeightIs int Returns weight of edge from Source to Destination
  47. GetToVertices void Returns a queue of vertices adjacent to specified vertex
  48. ClearMarks void Sets all vertex marks to false
  49. Fall 2008 CPE212 Project Assignment Project 8
  50. Page 5 of 5
  51. MarkVertex void Sets mark of specified vertex to true
  52. IsMarked bool Returns mark status of specified vertex
  53. Print void Prints Graph contents in specified format (see sample solution)
  54. DepthFirstSearch Queue* Returns pointer to a queue containing the path if found. If not
  55. found, returns NULL pointer
  56. ~Graph N/A Deallocates all edge nodes and the vertex array
  57. Note: Load function described in “graph.h
  58.  See the file graph.h for additional details regarding the function interfaces 
Reply With Quote