Lab

Graph


Prelab Task:

1. Understand what we learned about graph (i.e. graph creation and graph operations) and read the related book materials

 2. Read and understand  "d_graph.h"

3. Create a data file named graphA.dat for the graph A. The format of the data file is given in graph.dat, where m is the number of vertices in graph, n is number of edges, weight_i is the weight of edge from source_i to destination_i . You will use the data file you created for graph A in this lab.

 

 Lab Task:

 

In this lab, you will create a data file for a graph and carry out common graph operations on it.

  1. Copy "d_graph.h",  "d_galgs.h", and "d_util.h" into your working directory. These files may be used in your program

  2. Write your program in a file named lab_09.cpp. Your program will first input the data file for the graph A, and then carry out the following tasks:

    1. Insert an edge from F to D with weight 1

    2. Delete vertex B

    3. Erase the edge (A,D)

    4. Prompt the user to input a vertex, and list all the neighbors of the vertex

    5. Insert the new vertex G

    6. Add the following edges with weight  1: (G,C), (G,F), (D,G).

    7. Output the graph using the operator <<

What to Turn In