i am trying to implement Graph ADT in c++ here is code
#include <iostream>
using namespace std;
struct Edge{
int v,w;
Edge( int t=-1,int k=-1):v(t),w(k){}
};
class Graph {
public:
Graph(int,bool);
~Graph();
int V() const;
int E() const;
bool directed() const;
int remove(Edge);
int insert(Edge);
bool edge(int,int);
class AdjIterator{
public:
AdjIterator(const Graph&,int);
int beg();
int nxt();
bool end();
};
};
int main(){
return 0;
}
how good is this kind of implementation according to performance of code? Edited: i have added this code
template<class Graph>
vector<Edge> edge(Graph& G){
int E=0;
vector<Edge>a(G.E());
for (int v=0;v<G.V();v++){
typename Graph::AdjIterator A(G,v);
for (int w=A.beg();w!=A.end();w=A.nxt())
if (G.directed() || v<w)
a[E++]=Edge(v,w);
}
return a;
}