44 lines
No EOL
1.7 KiB
C++
44 lines
No EOL
1.7 KiB
C++
// Corey Williams
|
|
// COP3530 01Z
|
|
// Project 12
|
|
|
|
/*
|
|
Create an application that will build a directed graph, G = (V,E); refer to pg. 391.
|
|
The user will be prompted for the graph elements using a loop.
|
|
|
|
User will provide the number of nodes, N
|
|
User will provide the connectivity information (i.e.,
|
|
"whether edge exist between all combination of points", e.g., 2 to 4) stored in an N x N, 2-D array.
|
|
Use the adjacency matrix representation described on pg. 393
|
|
Application will create the nodes and build the graph using information stored in the 2-D array (passed to "Graph" constructor).
|
|
|
|
The "Graph" class will be composed of a vector, V, of "GraphNode" objects
|
|
|
|
The data members of the "GraphNode" class will be as follows.
|
|
pointNum "int"
|
|
connectedNodes "vector of pointers/references" // this will be a vector to this "GraphNode" type; storing all adjacent nodes
|
|
The "addGraphNode" method will add a "GraphNode" object to the "GraphNode" vector, V.
|
|
This method will require connectivity information also, which describes how the new node is connected to the other nodes in the graph.
|
|
|
|
|
|
Notes
|
|
The "Graph" class will represent the graph as an adjacency list (see Figure 8.2 (c) pg. 394.
|
|
The only difference being that the Project 12 Description is using vectors instead of
|
|
linked list where possible to simplify the implementation.
|
|
For C++ code, the "Graph" class should also have a destructor to release the allocated memory of the "GraphNode" objects.
|
|
|
|
*/
|
|
|
|
#include <iostream>
|
|
#include "digraph.h"
|
|
|
|
int main() {
|
|
int nodes;
|
|
|
|
cout << "How many nodes will the digraph have?\nEnter number of nodes: ";
|
|
cin >> nodes;
|
|
|
|
vector<vector<int>> relations;
|
|
|
|
|
|
} |