2 * Copyright (c) 2016-2019, S. Gilles <sgilles@math.umd.edu>
4 * Permission to use, copy, modify, and/or distribute this software
5 * for any purpose with or without fee is hereby granted, provided
6 * that the above copyright notice and this permission notice appear
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
13 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
14 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
15 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 /* A rational number */
28 /* The structure for a vertex */
30 /* A textual identifier for this vertex */
33 /* Whether this vertex is `fat' or not. Expected to be 1, 2, or 3. */
36 /* Drawing data: coordinates in `internal coordinates */
40 /* Drawing data: color */
46 /* The cluster algebra structure */
48 /* How many vertices there actually are in the quiver */
51 /* How many vertices we have allocated memory for */
57 /* Edges - e_{ij} (fatness included, so E^t is not necessarily -E) */
60 /* For detecting if quiver_mutate() creates an edge too high */
61 unsigned int edge_weight_threshold
;
64 /* Add an arrow of weight a/b from i -> j, affecting e(i,j) and e(j,i) */
65 int quiver_add_to_edge(struct quiver
*q
, size_t i
, size_t j
, int_fast32_t a
,
66 uint_fast32_t b
, const char **out_errstr
);
68 /* Add a vertex with a name and weight */
69 int quiver_add_vertex(struct quiver
*q
, size_t *out_i
, const char *name
,
70 uint_fast16_t fatness
, int x
, int y
, uint32_t argb
, const
73 /* Increase or decrease the fatness of a vertex, readjusting edges as well */
74 int quiver_adjust_fatness(struct quiver
*q
, size_t i
, int_fast8_t fatness
, const
77 /* Free all memory used by this quiver, resetting it to { 0 } */
78 int quiver_clean(struct quiver
*q
);
80 /* Delete a vertex (and all associated edges) */
81 int quiver_delete_vertex(struct quiver
*q
, size_t i
, const char **out_errstr
);
84 int quiver_get_sigma(const struct quiver
* const q
, size_t i
, size_t j
, struct
87 /* Read quiver from file */
88 int quiver_load_from_file(struct quiver
*q
, FILE *f
, const char **out_errstr
);
91 int quiver_rename_vertex(struct quiver
*q
, size_t i
, const char *new_name
, const
94 /* Recolor a vertex */
95 int quiver_color_vertex(struct quiver
*q
, size_t i
, uint32_t argb
, const
98 /* Serialize the quiver */
99 int quiver_save_to_file(struct quiver
*q
, FILE *f
, const char **out_errstr
);
101 /* Set threshold: if quiver_mutate() creates an edge above, warn_out is set */
102 int quiver_set_warning_threshold(struct quiver
*q
, unsigned int warn_threshold
,
103 const char **out_errstr
);
105 /* Mutate the quiver at vertex k, setting warn_out if threshold is broken */
106 int quiver_mutate(struct quiver
*q
, size_t k
, int *out_warn
, const