Yes, this is a homework assignment (before you ask), but I'm having troubles and I feel like people on here are much less pretentious than my fellow CS students.
My question is, what would I need to do to create a matrix in a template graph class in c++ using a two dimensional vector. I always can visualize what I need to do, but run into troubles when it comes to typing it out.
Here is what I have so far:
using namespace std;
namespace GraphNameSpace
{
enum isDirected {DIRECTED, UNDIRECTED};
enum isWeighted {WEIGHTED, UNWEIGHTED};
template <class T>
class Graph
{
public:
Graph<T>();
Graph<T>(isDirected);
Graph<T>(isWeighted);
Graph<T>(isDirected, isWeighted);
Graph<T>(isWeighted, isDirected);
void createMatix();
void destroy();
bool isEmpty() const;
bool isFull() const;
bool isAdjacentTo(T fromVertex, T toVertex) const;
int edgeWeight(T fromVertex, T toVertex) const;
int edgeCount() const;
int vertexCount() const;
void insertVertex(T Vertex);
void insertEdge(T fromVertex, T toVertex, int weight);
void deleteVertex(T Vertex);
void deleteEdge(T fromVertex, T toVertex);
int findVertex(T Vertex) const;
void dump() const;
private:
vector<int> row(100);
int numVertices;
int numEdges;
static isDirected dir;
static isWeighted wght;
};
}
I guess the problem is with the vector row(100), but may also be with the void createMatrix(). I'm just desperately trying to understand how to do this, so an explanation with example code would be appreciated. (The rest of the code is exactly as he wants it). Thanks in advance for trying to help me, it's deeply appreciated.