24#define ORIGE(e) (ED_to_orig(e))
79#pragma GCC diagnostic push
80#pragma GCC diagnostic ignored "-Wcast-qual"
89#pragma GCC diagnostic pop
100 deglist_append(&dl, n);
115 int has_pair_count = 0;
116 int no_pair_count = 0;
148 neighbors_with[has_pair_count] = n1;
151 neighbors_without[no_pair_count] = n1;
162 if (diff < no_pair_count) {
164 if ((
mark + 1) >= no_pair_count)
166 tp = neighbors_without[
mark];
167 hp = neighbors_without[
mark + 1];
176 tp = neighbors_without[0];
177 hp = neighbors_without[
mark];
186 else if (diff == no_pair_count) {
187 tp = neighbors_with[0];
189 hp = neighbors_without[
mark];
197 free(neighbors_without);
198 free(neighbors_with);
216 while (counter < nodeCount - 3) {
217 currnode = deglist_is_empty(&dl) ?
NULL : deglist_pop_back(&dl);
222 if (currnode == adjNode)
224 deglist_remove(&dl, adjNode);
231 if (currnode == adjNode)
235 deglist_append(&dl, adjNode);
296 nodelist_t beginPath = {0};
298 nodelist_append(&beginPath, n);
315 if (length > maxlength) {
321 nodelist_t beginPath = {0};
323 nodelist_append(&beginPath, n);
326 nodelist_append(&beginPath, common);
421 for (
size_t item = 0;
item < nodelist_size(list); ++
item) {
422 n = nodelist_get(list,
item);
429 for (eitem =
dtfirst(openEdgeList); eitem;
430 eitem =
dtnext(openEdgeList, eitem)) {
464 int crossings, j, newCrossings;
476 for (j = 0; j < 2; j++) {
477 nodelist_t listCopy = nodelist_copy(&list);
480 if (newCrossings < crossings) {
481 crossings = newCrossings;
482 nodelist_free(&listCopy);
483 if (crossings == 0) {
488 nodelist_free(&list);
499 int i, crossings, origCrossings;
506 origCrossings = crossings;
507 list =
reduce(list, subg, &crossings);
509 if (origCrossings == crossings || crossings == 0)
520 for (
size_t item = 0;
item < nodelist_size(list); ++
item) {
535 nodelist_t neighbors = {0};
538 nodelist_append(&neighbors,
aghead(e));
542 nodelist_append(&neighbors,
agtail(e));
547 if (nodelist_size(&neighbors) >= 2) {
548 for (
size_t one = 0; one < nodelist_size(list); ++one) {
549 const size_t two = (one + 1) % nodelist_size(list);
551 if (
NEIGHBOR(nodelist_get(list, one)) &&
552 NEIGHBOR(nodelist_get(list, two))) {
561 if (!placed && !nodelist_is_empty(&neighbors)) {
562 for (
size_t one = 0; one < nodelist_size(list); ++one) {
563 if (
NEIGHBOR(nodelist_get(list, one))) {
572 nodelist_append(list, n);
574 for (
size_t one = 0; one < nodelist_size(&neighbors); ++one)
576 nodelist_free(&neighbors);
595 double theta, radius, largest_node;
611 size_t N = nodelist_size(&longest_path);
617 radius = (double)
N * (min_dist + largest_node) / (2 *
M_PI);
619 for (
size_t item = 0;
item < nodelist_size(&longest_path); ++
item) {
629 for (
size_t item = 0;
item < nodelist_size(&longest_path); ++
item) {
633 theta = k * (2.0 *
M_PI / (double)
N);
635 ND_pos(n)[0] = radius * cos(theta);
636 ND_pos(n)[1] = radius * sin(theta);
642 sn->
radius = largest_node / 2;
661 fprintf(stderr,
"%s ",
agnameof(n));
static void agxbfree(agxbuf *xb)
free any malloced resources
static int agxbprint(agxbuf *xb, const char *fmt,...)
Printf-style output to an agxbuf.
static WUR char * agxbuse(agxbuf *xb)
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
static int count_all_crossings(nodelist_t *list, Agraph_t *subg)
static void place_node(Agraph_t *g, Agnode_t *n, nodelist_t *list)
Add n to list. By construction, n is not in list at start.
static nodelist_t find_longest_path(Agraph_t *tree)
Find and return longest path in tree.
static void block_graph(Agraph_t *g, block_t *sn)
Add induced edges.
static nodelist_t reduce(nodelist_t list, Agraph_t *subg, int *cnt)
static int cmpDegree(const Agnode_t **a, const Agnode_t **b)
comparison function for sorting nodes by degree, descending
static void place_residual_nodes(Agraph_t *g, nodelist_t *list)
Add nodes not in list to list.
static void dfs(Agraph_t *g, Agnode_t *n, Agraph_t *tree)
Simple depth first search, adding traversed edges to tree.
static double largest_nodesize(nodelist_t *list)
Return max dimension of nodes on list.
static Agraph_t * spanning_tree(Agraph_t *g, circ_state *state)
static void find_pair_edges(Agraph_t *g, Agnode_t *n, Agraph_t *outg)
static void measure_distance(Agnode_t *n, Agnode_t *ancestor, int dist, Agnode_t *change)
static Agraph_t * clone_graph(Agraph_t *ing, Agraph_t **xg, circ_state *state)
static Agraph_t * remove_pair_edges(Agraph_t *ing, circ_state *state)
static deglist_t getList(Agraph_t *g)
Add nodes to deg_list, storing them by descending degree.
nodelist_t layout_block(Agraph_t *g, block_t *sn, double min_dist, circ_state *state)
static nodelist_t reduce_edge_crossings(nodelist_t list, Agraph_t *subg)
#define UNSET_NEIGHBOR(n)
void add_edge(edgelist *list, Agedge_t *e)
edgelist * init_edgelist(void)
void free_edgelist(edgelist *list)
void remove_edge(edgelist *list, Agedge_t *e)
static void endPath(bezier_path_t *polypath)
static double dist(int dim, double *x, double *y)
static int cnt(Dict_t *d, Dtlink_t **set)
int agnnodes(Agraph_t *g)
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 * agnxtedge(Agraph_t *g, Agedge_t *e, Agnode_t *n)
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
Agedge_t * agfstedge(Agraph_t *g, Agnode_t *n)
Agedge_t * agfstin(Agraph_t *g, Agnode_t *n)
int agclose(Agraph_t *g)
deletes a graph, freeing its associated storage
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)
Agnode_t * agsubnode(Agraph_t *g, Agnode_t *n, int createflag)
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,...
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 * agsubg(Agraph_t *g, char *name, int cflag)
static void mark(const stk_t *stk, Agnode_t *n)
set a mark on n
#define DEFINE_LIST(name, type)
#define neighbor(t, i, edim, elist)
void realignNodelist(nodelist_t *list, size_t np)
Make np new front of list, with current last hooked to current first.
void insertNodelist(nodelist_t *list, Agnode_t *cn, Agnode_t *neighbor, int pos)
void reverseAppend(nodelist_t *l1, nodelist_t *l2)
Create l1 @ (rev l2) Destroys and frees l2.
void appendNodelist(nodelist_t *list, size_t one, Agnode_t *n)
Add node after one.
int graphCopyCount
how many cloned graphs have we created?
int spanningTreeCount
how many spanning trees have we created?