-
Notifications
You must be signed in to change notification settings - Fork 4
/
dat_adt_adj.cc
46 lines (40 loc) · 875 Bytes
/
dat_adt_adj.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
struct Edge {
int v, int w;
Edge (int v = -1, int w = -1): v(v), w(w) {}
}
class GRAPH {
private:
// Implementation-dependent code
public:
GRAPH (int, bool);
GRAPH();
int V() const;
int N() const;
bool directed() const;
int insert (Edge);
int remove (Edge);
bool edge (int, int);
class adjIterator {
public:
adjIterator(const GRAPH &, int);
int beg();
int nxt();
bool end();
};
};
template <class Graph>
class IO{
public:
static void show (const Graph &G);
static void scanEZ (Graph &);
static void scan (Graph &);
}
void IO<Graph>::show (const Graph &G){
for (int s=0; s<G.V(); s++){
cout.width(2);
cout << s << ":";
typename Graph::adjIterator A(G, s);
for (int t = A.beg(); !A.end(); t = A.nxt())
{cout.width(2); cout << t << " ";}
}
}