Skip to content
David edited this page Sep 20, 2018 · 5 revisions

Summary

This project was made with a a team member at my school. It can be improved in a lot of ways.

At least 3 techniques were used for this project. First of all, the template technique was used within all our classes. In fact, the class Node has a value and it can be of any type. This template value was called ‘T’. Thus, in the Driver file, every class is using the T type value as an integer to tell us that we are using integers. Second of all, exception handling was used in the addNode and the addEdge methods. In the addNode method, the try-catch exception looks if the size of the node list of the graph is less than 100. Here, the limit can be changed to anything. We simply decided that the limit would 100 in this case. If the list is bigger than 100, it will throw exception and stop the program. In the addEdge method, the try-catch exception looks if there are less than 2 nodes in the node list because we cannot add an edge if there are less than 2 nodes in a graph. If the list is less than 2, then it will throw exception and stops the program. Afterwards, operator overloading was used with the output stream ‘<<’ operator. It is used in all classes to display the information. It will display the node, edge and graph’s information. It will also display the path for a directed or undirected graph. Finally, inheritance was used with DirectGraph and UnDirectedGraph classes being the derived classes of the base class Graph. When a Directed Graph or an Undirected Graph is initialized, it will take the Graph’s information by simply initializing it with member initialization in the constructor and the copy constructor.

The Member Function Diagram

First off, you can create nodes.

1

You can also create edges.

2

Then, you can add edges and nodes to the graph. You can list, remove and see if there are duplicates in the lists.

3

Next, graphs can be Directed. The path can be shown directly on the next picture.

4

Finally, graphs can also be Undirected.

5

Clone this wiki locally