You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
5.3 KiB

  1. /**
  2. @file
  3. @ingroup mtr
  4. @brief Multiway-branch tree manipulation
  5. @details This package provides two layers of functions. Functions
  6. of the lower level manipulate multiway-branch trees, implemented
  7. according to the classical scheme whereby each node points to its
  8. first child and its previous and next siblings. These functions are
  9. collected in mtrBasic.c.<p>
  10. Functions of the upper layer deal with group trees, that is the trees
  11. used by group sifting to represent the grouping of variables. These
  12. functions are collected in mtrGroup.c.
  13. @see The CUDD package documentation; specifically on group
  14. sifting.
  15. @author Fabio Somenzi
  16. @copyright@parblock
  17. Copyright (c) 1995-2015, Regents of the University of Colorado
  18. All rights reserved.
  19. Redistribution and use in source and binary forms, with or without
  20. modification, are permitted provided that the following conditions
  21. are met:
  22. Redistributions of source code must retain the above copyright
  23. notice, this list of conditions and the following disclaimer.
  24. Redistributions in binary form must reproduce the above copyright
  25. notice, this list of conditions and the following disclaimer in the
  26. documentation and/or other materials provided with the distribution.
  27. Neither the name of the University of Colorado nor the names of its
  28. contributors may be used to endorse or promote products derived from
  29. this software without specific prior written permission.
  30. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  33. FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  34. COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  35. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  36. BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  37. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  38. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  39. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  40. ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  41. POSSIBILITY OF SUCH DAMAGE.
  42. @endparblock
  43. */
  44. #ifndef MTR_H_
  45. #define MTR_H_
  46. /*---------------------------------------------------------------------------*/
  47. /* Nested includes */
  48. /*---------------------------------------------------------------------------*/
  49. #include <stdio.h>
  50. #ifdef __cplusplus
  51. extern "C" {
  52. #endif
  53. /*---------------------------------------------------------------------------*/
  54. /* Constant declarations */
  55. /*---------------------------------------------------------------------------*/
  56. /* Flag definitions */
  57. #define MTR_DEFAULT 0x00000000
  58. #define MTR_TERMINAL 0x00000001
  59. #define MTR_SOFT 0x00000002
  60. #define MTR_FIXED 0x00000004
  61. #define MTR_NEWNODE 0x00000008
  62. /*---------------------------------------------------------------------------*/
  63. /* Stucture declarations */
  64. /*---------------------------------------------------------------------------*/
  65. /*---------------------------------------------------------------------------*/
  66. /* Type declarations */
  67. /*---------------------------------------------------------------------------*/
  68. /**
  69. * @brief multi-way tree node.
  70. */
  71. typedef struct MtrNode_ MtrNode;
  72. /*---------------------------------------------------------------------------*/
  73. /* Variable declarations */
  74. /*---------------------------------------------------------------------------*/
  75. /*---------------------------------------------------------------------------*/
  76. /* Macro declarations */
  77. /*---------------------------------------------------------------------------*/
  78. /*---------------------------------------------------------------------------*/
  79. /* Function prototypes */
  80. /*---------------------------------------------------------------------------*/
  81. MtrNode * Mtr_AllocNode(void);
  82. void Mtr_DeallocNode(MtrNode *node);
  83. MtrNode * Mtr_InitTree(void);
  84. void Mtr_FreeTree(MtrNode *node);
  85. MtrNode * Mtr_CopyTree(MtrNode const *node, int expansion);
  86. void Mtr_MakeFirstChild(MtrNode *parent, MtrNode *child);
  87. void Mtr_MakeLastChild(MtrNode *parent, MtrNode *child);
  88. MtrNode * Mtr_CreateFirstChild(MtrNode *parent);
  89. MtrNode * Mtr_CreateLastChild(MtrNode *parent);
  90. void Mtr_MakeNextSibling(MtrNode *first, MtrNode *second);
  91. void Mtr_PrintTree(MtrNode const *node);
  92. MtrNode * Mtr_InitGroupTree(int lower, int size);
  93. MtrNode * Mtr_MakeGroup(MtrNode *root, unsigned int low, unsigned int high, unsigned int flags);
  94. MtrNode * Mtr_DissolveGroup(MtrNode *group);
  95. MtrNode * Mtr_FindGroup(MtrNode *root, unsigned int low, unsigned int high);
  96. int Mtr_SwapGroups(MtrNode *first, MtrNode *second);
  97. void Mtr_ReorderGroups(MtrNode *treenode, int *permutation);
  98. void Mtr_PrintGroups(MtrNode const *root, int silent);
  99. int Mtr_PrintGroupedOrder(MtrNode const * root, int const *invperm, FILE *fp);
  100. MtrNode * Mtr_ReadGroups(FILE *fp, int nleaves);
  101. #ifdef __cplusplus
  102. }
  103. #endif
  104. #endif /* MTR_H_ */