45static void renewlist(
elist *
L, edge_set_t *track) {
46 for (
size_t i =
L->size; i !=
SIZE_MAX; i--) {
47 if (track !=
NULL &&
L->list[i] !=
NULL) {
67 const edge_t *
const *a = x;
68 const edge_t *
const *b = y;
69 const uintptr_t addr_a = (uintptr_t)*a;
70 const uintptr_t addr_b = (uintptr_t)*b;
71 if (addr_a < addr_b) {
74 if (addr_a > addr_b) {
83 edge_set_t to_free = {0};
85 for (
size_t c = 0; c <
GD_comp(g).size; c++) {
91 renewlist(&
ND_out(n), &to_free);
143 for (
size_t i = 0; i <
LIST_SIZE(&to_free); ++i) {
145 if (current != previous) {
146 if (previous !=
NULL) {
153 if (previous !=
NULL) {
297 assert(leader !=
NULL);
381 while ((e =
ND_out(n).list[0])) {
388 while ((e =
ND_in(n).list[0])) {
421 int maxiter = INT_MAX;
424 if ((
s =
agget(g,
"nslimit1")))
426 for (
size_t c = 0; c <
GD_comp(g).size; c++) {
500 fprintf(stderr,
"Maxrank = %d, minrank = %d\n",
GD_maxrank(g),
510#define ROOT "\177root"
515#define ND_comp(n) ND_hops(n)
526 const char *
const str =
agget(g,
"rank");
597 clust = parent_clust;
667 if (par == ct || par == ch)
713 (e =
agedge(g, t, h, 0, 1)))
716 agerrorf(
"ranking: failure to create strong constraint edge between nodes "
768 for (e =
agfstout(g, v); e; e = f) {
839 for (i = 1; i <= ncc; i++)
907 (void)
agedge(g, root, n, 0, 1);
949 int ncc, maxiter = INT_MAX;
960 if ((
s =
agget(g,
"nslimit1")))
972 if ((
s =
agget(g,
"searchsize")))
976 rank2(Xg, 1, maxiter, ssize);
Memory allocation wrappers that exit on failure.
static void * gv_recalloc(void *ptr, size_t old_nmemb, size_t new_nmemb, size_t size)
static void * gv_calloc(size_t nmemb, size_t size)
bool mapbool(const char *p)
node_t * UF_union(node_t *u, node_t *v)
node_t * UF_find(node_t *n)
void UF_singleton(node_t *u)
bool is_a_cluster(Agraph_t *g)
void decompose(graph_t *g, int pass)
Agraph_t * dot_root(void *p)
Agedge_t * virtual_edge(Agnode_t *, Agnode_t *, Agedge_t *)
int agnedges(Agraph_t *g)
int agnnodes(Agraph_t *g)
char * agget(void *obj, char *name)
char * agxget(void *obj, Agsym_t *sym)
void agpushdisc(Agraph_t *g, Agcbdisc_t *disc, void *state)
Agedge_t * agedge(Agraph_t *g, Agnode_t *t, Agnode_t *h, char *name, int createflag)
Agedge_t * agsubedge(Agraph_t *g, Agedge_t *e, int createflag)
Agedge_t * agnxtin(Agraph_t *g, Agedge_t *e)
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
#define agfindedge(g, t, h)
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
Agedge_t * agfstin(Agraph_t *g, Agnode_t *n)
void agwarningf(const char *fmt,...)
void agerrorf(const char *fmt,...)
int agclose(Agraph_t *g)
deletes a graph, freeing its associated storage
Agdesc_t Agstrictdirected
strict directed. A strict graph cannot have multi-edges or self-arcs.
Agraph_t * agopen(char *name, Agdesc_t desc, Agdisc_t *disc)
creates a new graph with the given name and kind
Agnode_t * agnode(Agraph_t *g, char *name, int createflag)
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Agnode_t * agfstnode(Agraph_t *g)
char * agnameof(void *)
returns a string descriptor for the object.
int agdelete(Agraph_t *g, void *obj)
deletes object. Equivalent to agclose, agdelnode, and agdeledge for obj being a graph,...
int agcontains(Agraph_t *, void *obj)
returns non-zero if obj is a member of (sub)graph
void * agbindrec(void *obj, const char *name, unsigned int recsize, int move_to_front)
attaches a new record of the given size to the object
Agraph_t * agfstsubg(Agraph_t *g)
Agraph_t * agnxtsubg(Agraph_t *subg)
Agraph_t * graph(char *name)
Arithmetic helper functions.
static int scale_clamp(int original, double scale)
scale up or down a non-negative integer, clamping to [0, INT_MAX]
textitem scanner parser str
void reverse_edge(edge_t *e)
type-generic dynamically expanding list
#define LIST_APPEND(list,...)
#define LIST_SORT(list, cmp)
#define LIST_GET(list, index)
int rank(graph_t *g, int balance, int maxiter)
int rank2(graph_t *g, int balance, int maxiter, int search_size)
static void dfscc(graph_t *g, node_t *n, int cc)
static int make_new_cluster(graph_t *g, graph_t *subg)
static bool is_internal_to_cluster(edge_t *e)
static void compile_samerank(graph_t *ug, graph_t *parent_clust)
static char rankset_kind(graph_t *g)
static void compile_edges(graph_t *ug, graph_t *Xg)
void dot_scan_ranks(graph_t *g)
static graph_t * dot_lca(graph_t *c0, graph_t *c1)
static char rank_set_class(graph_t *g)
static void expand_ranksets(graph_t *g)
static int connect_components(graph_t *g)
static void node_induce(graph_t *par, graph_t *g)
static void readout_levels(graph_t *g, graph_t *Xg, int ncc)
static void setMinMax(graph_t *g, int doRoot)
static void collapse_cluster(graph_t *g, graph_t *subg)
static void cleanup1(graph_t *g)
static bool is_empty(graph_t *g)
static void merge(edge_t *e, int minlen, int weight)
static int minmax_edges2(graph_t *g, point slen)
void dot_rank(graph_t *g)
static int edge_ptr_cmp(const void *x, const void *y)
static void dfs(graph_t *g, node_t *v)
static point minmax_edges(graph_t *g)
static node_t * union_one(node_t *leader, node_t *n)
static void find_clusters(graph_t *g)
static void collapse_sets(graph_t *rg, graph_t *g)
static bool is_nonconstraint(edge_t *e)
static void strong(graph_t *g, node_t *t, node_t *h, edge_t *orig)
static void set_parent(graph_t *g, graph_t *p)
static node_t * Last_node
static void my_init_graph(Agraph_t *g, Agobj_t *graph, void *arg)
static node_t * find(node_t *n)
static node_t * makeXnode(graph_t *G, char *name)
static void reverse_edge2(graph_t *g, edge_t *e)
static void add_fast_edges(graph_t *g)
static void break_cycles(graph_t *g)
static void dot1_rank(graph_t *g)
static void compile_nodes(graph_t *g, graph_t *Xg)
static void dot2_rank(graph_t *g)
static void collapse_rankset(graph_t *g, graph_t *subg, char kind)
static void cluster_leader(graph_t *clust)
static void my_init_node(Agraph_t *g, Agobj_t *node, void *arg)
static void edgelabel_ranks(graph_t *g)
static void my_init_edge(Agraph_t *g, Agobj_t *edge, void *arg)
static node_t * union_all(graph_t *g)
static void set_minmax(graph_t *g)
static bool streq(const char *a, const char *b)
are a and b equal?
client event callbacks, used in Agcbstack_s
a generic header of Agraph_s, Agnode_s and Agedge_s
Agrec_t * data
stores programmer-defined data, access with AGDATA
#define elist_append(item, L)
#define alloc_elist(n, L)