24 #define ORIGE(e) (ED_to_orig(e))
43 sprintf(gname,
"_clone_%d",
id++);
44 clone =
agsubg(ing, gname,1);
46 sprintf(gname,
"_clone_%d",
id++);
99 int has_pair_count = 0;
100 int no_pair_count = 0;
132 neighbors_with[has_pair_count] = n1;
135 neighbors_without[no_pair_count] = n1;
140 diff = node_degree - 1 - edge_cnt;
146 if (diff < no_pair_count) {
147 for (mark = 0; mark < no_pair_count; mark += 2) {
148 if ((mark + 1) >= no_pair_count)
150 tp = neighbors_without[mark];
151 hp = neighbors_without[mark + 1];
160 tp = neighbors_without[0];
161 hp = neighbors_without[mark];
170 else if (diff == no_pair_count) {
171 tp = neighbors_with[0];
172 for (mark = 0; mark < no_pair_count; mark++) {
173 hp = neighbors_without[mark];
181 free(neighbors_without);
182 free(neighbors_with);
199 outg = clone_graph(ing, &g);
203 while (counter < (nodeCount - 3)) {
209 if (currnode == adjNode)
214 find_pair_edges(g, currnode, outg);
218 if (currnode == adjNode)
254 }
else if (dist >
DISTONE(parent)) {
255 if (
LEAFONE(parent) != change) {
263 }
else if (dist >
DISTTWO(parent)) {
270 measure_distance(n, parent, dist, change);
300 measure_distance(n, n, 0,
NULL);
306 if (length > maxlength) {
350 dfs(g, neighbor, tree);
365 sprintf(gname,
"_span_%d",
id++);
366 tree =
agsubg(g, gname,1);
418 for (item = list->
first; item; item = item->
next) {
452 #define CROSS_ITER 10
465 int crossings, j, newCrossings;
474 if (neighbor == curnode)
477 for (j = 0; j < 2; j++) {
480 newCrossings = count_all_crossings(list, subg);
481 if (newCrossings < crossings) {
482 crossings = newCrossings;
484 if (crossings == 0) {
502 int i, crossings, origCrossings;
504 crossings = count_all_crossings(list, subg);
509 origCrossings = crossings;
510 list = reduce(list, subg, &crossings);
512 if ((origCrossings == crossings) || (crossings == 0))
521 static double largest_nodesize(
nodelist_t * list)
527 for (item = list->
first; item; item = item->
next) {
558 for (one = list->
first; one; one = one->
next) {
559 if (one == list->
last)
574 for (one = list->
first; one; one = one->
next) {
586 for (one = neighbors->
first; one; one = one->
next)
600 place_node(g, n, list);
611 double theta, radius, largest_node;
617 copyG = remove_pair_edges(subg);
619 tree = spanning_tree(copyG);
620 longest_path = find_longest_path(tree);
621 place_residual_nodes(subg, longest_path);
625 longest_path = reduce_edge_crossings(longest_path, subg);
628 largest_node = largest_nodesize(longest_path);
633 radius = (N * (min_dist + largest_node)) / (2 *
M_PI);
635 for (item = longest_path->
first; item; item = item->
next) {
645 for (item = longest_path->
first; item; item = item->
next) {
649 theta = k * ((2.0 *
M_PI) / N);
651 ND_pos(n)[0] = radius * cos(theta);
652 ND_pos(n)[1] = radius * sin(theta);
658 sn->
radius = largest_node / 2;
677 fprintf(stderr,
"%s ",
agnameof(n));
CGRAPH_API Agnode_t * agnode(Agraph_t *g, char *name, int createflag)
CGRAPH_API Agraph_t * agopen(char *name, Agdesc_t desc, Agdisc_t *disc)
CGRAPH_API Agedge_t * agfstin(Agraph_t *g, Agnode_t *n)
void insertNodelist(nodelist_t *list, Agnode_t *cn, Agnode_t *neighbor, int pos)
Agnode_t * firstDeglist(deglist_t *list)
CGRAPH_API Agedge_t * agfstedge(Agraph_t *g, Agnode_t *n)
CGRAPH_API int agdelete(Agraph_t *g, void *obj)
CGRAPH_API Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
void insertDeglist(deglist_t *ns, Agnode_t *n)
void realignNodelist(nodelist_t *list, nodelistitem_t *np)
void add_edge(edgelist *list, Agedge_t *e)
nodelist_t * cloneNodelist(nodelist_t *list)
void freeDeglist(deglist_t *s)
CGRAPH_API Agnode_t * agtail(Agedge_t *e)
nodelist_t * mkNodelist()
void remove_edge(edgelist *list, Agedge_t *e)
CGRAPH_API Agraph_t * agsubg(Agraph_t *g, char *name, int cflag)
CGRAPH_API Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
CGRAPH_API Agnode_t * aghead(Agedge_t *e)
void reverseAppend(nodelist_t *l1, nodelist_t *l2)
int sizeNodelist(nodelist_t *list)
void free_edgelist(edgelist *list)
CGRAPH_API int agclose(Agraph_t *g)
CGRAPH_API char * agnameof(void *)
void freeNodelist(nodelist_t *list)
CGRAPH_API Agedge_t * agsubedge(Agraph_t *g, Agedge_t *e, int createflag)
CGRAPH_API Agnode_t * agfstnode(Agraph_t *g)
nodelist_t * layout_block(Agraph_t *g, block_t *sn, double min_dist)
void appendNodelist(nodelist_t *list, nodelistitem_t *one, Agnode_t *n)
CGRAPH_API Agedge_t * agnxtedge(Agraph_t *g, Agedge_t *e, Agnode_t *n)
CGRAPH_API int agnnodes(Agraph_t *g)
CGRAPH_API Agedge_t * agedge(Agraph_t *g, Agnode_t *t, Agnode_t *h, char *name, int createflag)
CGRAPH_API void * agbindrec(void *obj, char *name, unsigned int size, int move_to_front)
CGRAPH_API Agedge_t * agnxtin(Agraph_t *g, Agedge_t *e)
#define agfindedge(g, t, h)
#define UNSET_NEIGHBOR(n)
double dist(Site *s, Site *t)
CGRAPH_API Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
void removeDeglist(deglist_t *list, Agnode_t *n)
CGRAPH_API Agnode_t * agsubnode(Agraph_t *g, Agnode_t *n, int createflag)
edgelist * init_edgelist()
deglist_t * mkDeglist(void)