-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraph.h
More file actions
69 lines (52 loc) · 1.95 KB
/
Copy pathGraph.h
File metadata and controls
69 lines (52 loc) · 1.95 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
*
*CS372: Lab5
*File: Graph.h
*Author: August B. Sandoval
*Purpose: Provides the class definition of class Graph
*
**/
#ifndef GRAPH_H
#define GRAPH_H
#include <iostream>
#include <vector>
#include <list>
using namespace std;
class Graph{
private:
vector<Node> m_nodes;
vector< list<Node> > m_adjList;
bool Directed;
public:
friend ostream& operator<<(ostream & out, const Graph & g); //defined
Graph(const string & file);
Graph(const string & file, bool dir);
//Insert a edge ( a , b ) to m_adjList
void addEdge ( const Node & a , const Node & b ) ;//defined - need to check
//Insert a node a to m_nodes
void addNode ( const Node & a ); //defined
//check is the Node exist in the graph
//bool NodeExists(const Node & a)const;
bool NodeExist(const string& name)const; //defined
bool NodeExistAdj(const Node& a,size_t id)const;
//returns the id of the node with given name
size_t findID(const string& name)const; //defined
// Return node with id equal to i
Node & getNode ( size_t i ) ; //defined
const Node & getNode ( size_t i ) const; //defined
Node & getNode(size_t i);
// Return reference of the adjacency list of node a
list <Node> & getAdjNodes ( const Node & a );//defined
// Return constant reference to adjacency list of node a
const list <Node> & getAdjNodes ( const Node & a ) const; //defined
bool allExplored(size_t id)const;
// Return the total number of nodes i n the graph
size_t num_nodes ( ) const; //defined
// Create a graph from a tab−separated text edge list file
// t o adjacency lists
void scan ( const string & file ) ; //defined
// Save a graph from adjacency lists to a tab−separated
// text edge list file
void save ( const string & file ) ; //defined
};
#endif // GRAPH_H