circular.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*************************************************************************
  2. * Copyright (c) 2011 AT&T Intellectual Property
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * https://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors: Details at https://graphviz.org
  9. *************************************************************************/
  10. #pragma once
  11. #include "render.h"
  12. #include <circogen/block.h>
  13. typedef struct {
  14. blocklist_t bl;
  15. int orderCount;
  16. int blockCount;
  17. int graphCopyCount; ///< how many cloned graphs have we created?
  18. int spanningTreeCount; ///< how many spanning trees have we created?
  19. attrsym_t *N_root;
  20. char *rootname;
  21. double min_dist;
  22. } circ_state;
  23. typedef struct {
  24. Agnode_t *dnode;
  25. } ndata;
  26. /* Extra node data used for layout:
  27. * Pass O: build derived graph
  28. * Pass 1: construct blocks
  29. * Pass 2: construct block tree
  30. * Pass 3: layout block
  31. * a: construct block skeleton
  32. * b: construct skeleton spanning tree
  33. * c: construct circular list of nodes
  34. * Pass 4: connect blocks
  35. */
  36. typedef struct {
  37. union { /* Pointer to node/cluster in original graph */
  38. Agraph_t *g;
  39. Agnode_t *np;
  40. } orig;
  41. int flags;
  42. node_t *parent; /* parent in block-cutpoint traversal (1,2,4) */
  43. block_t *block; /* Block containing node (1,2,3,4) */
  44. union {
  45. struct { /* Pass 1 */
  46. node_t *next; /* used for stack */
  47. int val;
  48. int low_val;
  49. } bc;
  50. node_t *clone; /* Cloned node (3a) */
  51. struct { /* Spanning tree and longest path (3b) */
  52. node_t *tparent; /* Parent in tree */
  53. node_t *first; /* Leaf on longest path from node */
  54. node_t *second; /* Leaf on 2nd longest path from node */
  55. int fdist; /* Length of longest path from node */
  56. int sdist; /* Length of 2nd longest path from node */
  57. } t;
  58. struct {
  59. int pos; /* Index of node in block circle (3c,4) */
  60. double psi; /* Offset angle of children (4) */
  61. } f;
  62. } u;
  63. } cdata;
  64. typedef struct {
  65. int order;
  66. } edata;
  67. #define NDATA(n) ((ndata*)(ND_alg(n)))
  68. #define DNODE(n) (NDATA(n)->dnode)
  69. #define EDGEDATA(e) ((edata*)(ED_alg(e)))
  70. #define EDGEORDER(e) (EDGEDATA(e)->order)
  71. #define DATA(n) ((cdata*)(ND_alg(n)))
  72. #define ORIGG(n) (DATA(n)->orig.g)
  73. #define ORIGN(n) (DATA(n)->orig.np)
  74. #define FLAGS(n) (DATA(n)->flags)
  75. #define PARENT(n) (DATA(n)->parent)
  76. #define BLOCK(n) (DATA(n)->block)
  77. #define NEXT(n) (DATA(n)->u.bc.next)
  78. #define VAL(n) (DATA(n)->u.bc.val)
  79. #define LOWVAL(n) (DATA(n)->u.bc.low_val)
  80. #define CLONE(n) (DATA(n)->u.clone)
  81. #define TPARENT(n) (DATA(n)->u.t.tparent)
  82. #define LEAFONE(n) (DATA(n)->u.t.first)
  83. #define LEAFTWO(n) (DATA(n)->u.t.second)
  84. #define DISTONE(n) (DATA(n)->u.t.fdist)
  85. #define DISTTWO(n) (DATA(n)->u.t.sdist)
  86. #define POSITION(n) (DATA(n)->u.f.pos)
  87. #define PSI(n) (DATA(n)->u.f.psi)
  88. #define VISITED_F (1 << 0)
  89. #define ONSTACK_F (1 << 2)
  90. #define PARENT_F (1 << 3)
  91. #define PATH_F (1 << 4)
  92. #define NEIGHBOR_F (1 << 5)
  93. #define VISITED(n) (FLAGS(n)&VISITED_F)
  94. #define ONSTACK(n) (FLAGS(n)&ONSTACK_F)
  95. #define ISPARENT(n) (FLAGS(n)&PARENT_F)
  96. #define ONPATH(n) (FLAGS(n)&PATH_F)
  97. #define NEIGHBOR(n) (FLAGS(n)&NEIGHBOR_F)
  98. #define SET_VISITED(n) (FLAGS(n) |= VISITED_F)
  99. #define SET_ONSTACK(n) (FLAGS(n) |= ONSTACK_F)
  100. #define SET_PARENT(n) (FLAGS(n) |= PARENT_F)
  101. #define SET_ONPATH(n) (FLAGS(n) |= PATH_F)
  102. #define SET_NEIGHBOR(n) (FLAGS(n) |= NEIGHBOR_F)
  103. #define UNSET_VISITED(n) (FLAGS(n) &= ~VISITED_F)
  104. #define UNSET_ONSTACK(n) (FLAGS(n) &= ~ONSTACK_F)
  105. #define UNSET_NEIGHBOR(n) (FLAGS(n) &= ~NEIGHBOR_F)
  106. #define DEGREE(n) (ND_order(n))
  107. #include <circogen/circo.h>
  108. #ifdef __cplusplus
  109. extern "C" {
  110. #endif
  111. #ifdef DEBUG
  112. extern void prData(Agnode_t * n, int pass);
  113. #endif
  114. void circularLayout(Agraph_t *sg, Agraph_t *rg, int *blockCount);
  115. #ifdef __cplusplus
  116. }
  117. #endif