-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraph.h
58 lines (45 loc) · 1.56 KB
/
graph.h
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
#ifndef __GRAPH_INCLUDED_H__
#define __GRAPH_INCLUDED_H__
#include "node.h"
#include <map>
#include <string>
#include <vector>
#include <utility>
class graph {
public:
// To construct a graph object, you should supply all
// necessary informations.
graph (int, int);
graph& set_nodes (std::map<int, std::pair<int, int> > &);
graph& set_edges (std::vector< std::pair<int, int> > &);
// Constructor and Assignment overloading
graph (const graph & rhs);
graph& operator=(const graph & rhs);
// Destructor
~graph ();
// Update the graph by eaten nodes.
void update (const std::vector<int> &);
std::string str ();
void munch (int node_id, int player);
// Test if a nanomuncher could move in the direction of dir
// from node_id
bool is_adjacent_available (int node_id, char dir) const;
// Get the the adjecent node's id
int get_adjacent_node_id (int node_id, char dir) const;
std::vector< int > get_eaten_nodes () const;
// Player can utilize this method to generate
// random strategy
int get_random_uneaten_node () const;
private:
// Store the dimension of the board, within which
// our graph locates.
int x_size;
int y_size;
// The map below maps from the id of a node to its coordinate
std::map< int, std::pair<int, int> > id2coord;
std::vector< std::pair<int, int> > edges;
// The two dimensinal array is used to store the graph
// information. Each element is either a node or not a node.
node ** board;
};
#endif