Hello, I'm working on an assignment right now and I need some feedback. My project is to implement a graph that uses an adjacency list like an Edge list. I'm fairly new with these and I would apprecite if anyone can see my code if I'm on the right track. Thanks!
#include<iostream>
#include<string>
#include<list>
using namespace std;
#define D true
#define U false
#define W true
#define N false
#define MAX 100
class Edge
{
public:
Edge()
{
}
Edge(int from, int to, double weight = -1)
: from (from), to (to), weight (weight)
{
}
Edge(const Edge & other)
{
from = other.from;
to = other.to;
weight = other.weight;
}
Edge & operator=(const Edge & other)
{
this->from = other.from;
this->to = other.to;
this->weight = other.weight;
return *this;
}
int operator== (const Edge & other) const
{
if (this->from != other.from) return 0;
if (this->to != other.to) return 0;
if (this->weight != other.weight) return 0;
return 1;
}
int from;
int to;
bool directed;
double weight;
};
class Graph
{
public:
Graph(int n, bool directed, bool weighted)
: directed(directed), weighted(weighted)
{
}
void addEdge(Edge e)
{
list<Edge> adjList;
adjList.push_back(e);
}
bool isDirected()
{
return directed;
}
bool isWeighted()
{
return weighted;
}
int getNumVertices ();
int getNumEdges ();
private:
bool directed;
bool weighted;
Edge *adjList;
};
int main() {
Graph a(8, U, N);
Edge a0(0, 1);
Edge a1(1, 3);
Edge a2(6, 3);
Edge a3(4, 5);
Edge a4(1, 2);
Edge a5(3, 7);
Edge a6(3, 4);
a.addEdge(a0);
a.addEdge(a1);
a.addEdge(a2);
a.addEdge(a3);
a.addEdge(a4);
a.addEdge(a5);
a.addEdge(a6);
}