Starting from:
$30

$24

Homework 6 Solution

You will need to submit a written report with part of your codes and your source code via Blackboard. You also need to bring in a hard copy of the report with part of your codes to the class on the day that this is due.

Name your header file as LastName(3 to 5 letters)_FirstNameInitial_HW6_QX.h and your implementation file as LastName(3 to 5 letters)_FirstNameInitial_HW6_QX.cpp

Note: You can only use iostream, cassert, cctype, cmath, cstdio, and cstdlib.

1. Create a temple class called graph as an adjacency matrix with the following:

a. Private member variables for label/name for the vertices, weighted edges, and number of

vertices

b. Constructors (default and copy)

c. Add a vertex

d. Add an edge

e. Remove an edge

f. Print the edges as a matrix (neatly)

g. Return the size

h. Return number of edges

i. Return is there an edge between two vertices

j. Return the neighbors of a vertices

2. Same as question one but implemented as an adjacency list.

a. Instead of printing the edges as a matrix, print it as a list

3. Write the following as a template function:

a. Depth first

b. Breadth first

4. Write a function for Dijkstra’s algorithm.







Example structures of the report:

1. An overview of this homework

2. Code for question 1

3. Code for question 2

4. ... other questions

5. Any improvements, problems, etc. of the class/functions

Code should be Consolas font size 8 to 10.

More products