summaryrefslogtreecommitdiff
path: root/lib/include/graph.hpp
blob: c78fe9f8820e369b564fe396aeca8d1064387c4c (plain)
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

#pragma once

#include <algorithm>
#include <array>
#include <cmath>
#include <exception>
#include <list>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>

#include "array_hash.hpp"

class graph {
public:
  typedef struct coordinate {
    double x;
    double y;
  } coordinate;

  typedef struct vertex {
    coordinate r;
    std::vector<unsigned> nd;
    std::vector<unsigned> ne;
    std::vector<coordinate> polygon;
  } vertex;

  typedef struct edge {
    std::array<unsigned, 2> v;
    coordinate r;
    std::array<bool, 2> crossings;
  } edge;

  coordinate L;

  std::vector<vertex> vertices;
  std::vector<edge> edges;

  std::vector<vertex> dual_vertices;
  std::vector<edge> dual_edges;

  graph(unsigned Nx, unsigned Ny);
  graph(double Lx, double Ly, std::mt19937& rng);
  graph(unsigned n, double a, std::mt19937& rng);

  void helper(unsigned n, std::mt19937& rng);
  graph const rotate();

  std::string write() const;
};