Check more return codes
[clav.git] / quiver.h
bloba3ddb347bfaf3068b4612e5347a2ad3085a58279
1 /* A rational number */
2 struct rational {
3 /* Numerator */
4 int_fast8_t p;
6 /* Denominator */
7 uint_fast8_t q;
8 };
10 /* The structure for a vertex */
11 struct vertex {
12 /* A textual identifier for this vertex */
13 const char *name;
15 /* Whether this vertex is `fat' or not. Expected to be 1, 2, or 3. */
16 uint_fast8_t fatness;
18 /* Drawing data: coordinates in `internal coordinates */
19 int x;
20 int y;
23 /* The cluster algebra structure */
24 struct quiver {
25 /* How many vertices there actually are in the quiver */
26 size_t v_num;
28 /* How many vertices we have allocated memory for */
29 size_t v_len;
31 /* Vertices */
32 struct vertex *v;
34 /* Edges */
35 struct rational *e;
38 /* Add an arrow of weight a/b from i -> j, affecting e(i,j) and e(j,i) */
39 int
40 quiver_add_to_edge(struct quiver *q, size_t i, size_t j, int_fast8_t a,
41 uint_fast8_t b, const char **out_errstr);
43 /* Add a vertex with a name and weight */
44 int
45 quiver_add_vertex(struct quiver *q, size_t *out_i, const char *name,
46 uint_fast16_t fatness, int x, int y, const char **out_errstr);
48 /* Mutate the quiver at vertex k */
49 int
50 quiver_mutate(struct quiver *q, size_t k, const char **out_errstr);