-
Notifications
You must be signed in to change notification settings - Fork 4
/
graph64.hpp
80 lines (63 loc) · 2.05 KB
/
graph64.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef GRAPH64_HPP
#define GRAPH64_HPP
#include <iostream>
using std::cout; using std::endl;
#include <algorithm>
using std::sort;
#include "nautyinit.h"
typedef unsigned long uint32;
typedef unsigned long long uint64;
typedef struct
{
short matrix[64];
short size;
short g_N;
short g_M;
bool has_vertex_colors;
bool has_edge_colors;
unsigned short num_vertex_colors;
unsigned short num_edge_colors;
unsigned short num_vertex_bits;
unsigned short num_edge_bits;
bool directed;
uint64 codestamp;
graph nauty_canon[MAXN * MAXM];
graph nauty_g[MAXN * MAXM];
int lab[MAXN], ptn[MAXN], orbits[MAXN];
} graph64;
typedef uint64 graphcode64;
void init_graph(graph64 &g, short size, unsigned short num_vcolors,
unsigned short num_ecolors, bool directed);
graphcode64 toHashCode(graph64 &g);
void readHashCode(graph64 &g, graphcode64 gc);
graphcode64 getGraphID(graph64 &g, graphcode64 gc);
inline void delete_edge(graph64 &g, short source, short target) {
g.matrix[(source<<3)|target] = 0; //g.matrix[u*8+v] = 0;
DELELEMENT( ( GRAPHROW(g.nauty_g, source, g.g_M) ) , target);
}
inline void delete_vertex(graph64 &g, short idx) {
g.matrix[(idx<<3)|idx] = 0;
}
inline void delete_element(graph64 &g, short row, short col) {
g.matrix[(row<<3)|col] = 0;
DELELEMENT( ( GRAPHROW(g.nauty_g, row, g.g_M) ) , col);
}
inline void set_edge(graph64 &g, short source, short target) {
g.matrix[(source<<3)|target] = 1;
ADDELEMENT( ( GRAPHROW(g.nauty_g, source, g.g_M) ) , target);
}
inline void set_edge(graph64 &g, short source, short target, short color) {
g.matrix[(source<<3)|target] = color;
ADDELEMENT( ( GRAPHROW(g.nauty_g, source, g.g_M) ) , target);
}
inline void set_element(graph64 &g, short source, short target, short color) {
g.matrix[(source<<3)|target] = color;
ADDELEMENT( ( GRAPHROW(g.nauty_g, source, g.g_M) ) , target);
}
inline void color_vertex(graph64 &g, short idx, short color) {
g.matrix[(idx<<3)|idx] = color;
}
inline short get_element(const graph64 &g, const short row, const short col) {
return g.matrix[(row<<3)|col];
}
#endif