-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph.hpp
65 lines (59 loc) · 2.21 KB
/
graph.hpp
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
//#include <ext/hash_map>
#include <tr1/unordered_map>
#include <vector>
#include <set>
#include "edge.hpp"
#include <string>
//typedef __gnu_cxx::hash_map< uint, std::set<Edge>*> hmap;
//typedef __gnu_cxx::hash_map< uint, std::set<std::string>*> hmap_i_ss;
//typedef __gnu_cxx::hash_map< uint, std::string > hmap_i_s;
#ifndef CLUSTERING_GRAPH_H_
#define CLUSTERING_GRAPH_H_
#define MAXIMUM 999999999
typedef std::tr1::unordered_map< uint, std::set<Edge>*> hmap;
typedef std::tr1::unordered_map< uint, std::set<std::string>*> hmap_i_ss;
typedef std::tr1::unordered_map< uint, std::string > hmap_i_s;
typedef std::tr1::unordered_map< std::string, uint > hmap_s_i;
typedef std::tr1::unordered_map< uint, uint > hmap_i_i;
// Class definition. Will probably grow.
class Graph{
protected:
bool directed;
uint num_nodes;
uint num_edges;
double greatest_weight;
double smallest_weight;
void addEdge(uint node1, uint node2, double weight = 1.0);
void normalizeWeights();
hmap_i_s graph_labels;
hmap_s_i label_id;
public:
hmap graph_map;
// Gambiarra? sim, mas...
hmap_i_ss graph_attributes;
std::set<Edge>* getAdjacency(uint node);
void readFile(std::string filename);
void readGmlFile(std::string filename);
Graph(std::string filename);
Graph();
virtual ~Graph();
void print();
void printDotFile(std::string filename);
void printWeights();
uint getNumEdges();
uint getNumNodes();
std::set<std::string>* getVocabulary(uint node);
bool hasWord(uint node, std::string word);
void addWord(uint node, std::string word);
void dropVocabulary(uint node);
void printVocabularies();
std::string getNodeLabel(uint node);
void printDegreeDistroData();
void printOtterFile(std::string filename);
void printClutoFile(std::string filename);
bool isDirected();
hmap_i_i dijkstra(uint source);
uint getNodeLabelId(std::string label);
bool nodeLabelExists(std::string label);
};
#endif // CLUSTERING_GRAPH_H_