Select edges properly
[clav.git] / quiver.h
blobd5f26fedbcd7bdde98cae4b183c0430bf9c1607f
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 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 - e_{ij} (fatness included, so E^t is not necessarily -E) */
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 /* Increase or decrease the fatness of a vertex, readjusting edges as well */
49 int
50 quiver_adjust_fatness(struct quiver *q, size_t i, int_fast8_t fatness, const
51 char **out_errstr);
53 /* Delete a vertex (and all associated edges) */
54 int
55 quiver_delete_vertex(struct quiver *q, size_t i, const char **out_errstr);
57 /* Mutate the quiver at vertex k */
58 int
59 quiver_mutate(struct quiver *q, size_t k, const char **out_errstr);