Source code of Windows XP (NT5)
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.

126 lines
3.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1997
  6. //
  7. // File: cliqwork.h
  8. //
  9. //--------------------------------------------------------------------------
  10. //
  11. // cliqwork.h: Helper structures and templates for junction tree formation
  12. //
  13. #ifndef _CLIQWORK_H_
  14. #define _CLIQWORK_H_
  15. #include "algos.h" // Include the <algorithms> and additions
  16. class NDCQINFO
  17. {
  18. public:
  19. GNODEMBN * _pgnd; // Node pointer
  20. int _iCliqOrdSelf; // Index of ordered clique containing self
  21. int _iCliqOrdFamily; // Index of family clique (self & parents)
  22. NDCQINFO ()
  23. : _pgnd(NULL),
  24. _iCliqOrdSelf(-1),
  25. _iCliqOrdFamily(-1)
  26. {}
  27. DECLARE_ORDERING_OPERATORS(NDCQINFO);
  28. };
  29. inline bool NDCQINFO :: operator < ( const NDCQINFO & ndcq ) const
  30. {
  31. assert( _pgnd && ndcq._pgnd );
  32. return _pgnd->ITopLevel() < ndcq._pgnd->ITopLevel() ;
  33. }
  34. DEFINEV(NDCQINFO);
  35. DEFINEVP(GOBJMBN_CLIQUE);
  36. // Helper structure for cliquing
  37. class CLIQSETWORK
  38. {
  39. public:
  40. CLIQSETWORK ( GOBJMBN_CLIQSET & cliqset )
  41. : _cliqset(cliqset),
  42. _iElimIndex(-1),
  43. _cTrees(0)
  44. {}
  45. void PrepareForBuild ();
  46. void RenumberNodesForCliquing ();
  47. int CNodesCommon ( int iClique1, int iClique2 );
  48. int CNodesCommon ( const VPGNODEMBN & vpgnd1, const VPGNODEMBN & vpgnd2 );
  49. void SetCNodeMaxCommon ( int iClique1, int iCliqueOrdered2 );
  50. bool BUpdateCNodeMaxCommon ( int iClique );
  51. bool BBetter ( int iClique1, int iClique2 );
  52. void BuildCliques ();
  53. void SetTopologicalInfo ();
  54. void CreateTopology ();
  55. // Return the ordered index of a clique or -1 if not in the tree yet.
  56. int IOrdered ( int iClique );
  57. bool BCheckRIP ();
  58. bool BCheckRIP ( int iCliqueOrdered );
  59. void TopSortNodeCliqueInfo ();
  60. static void MarkSortNodePtrArray ( VPGNODEMBN & vpgnd );
  61. MBNET & Model ()
  62. { return _cliqset.Model(); }
  63. REAL REstimatedSize ();
  64. void DumpCliques ();
  65. void DumpClique ( int iClique );
  66. void DumpTree ();
  67. void DumpTopInfo ();
  68. public:
  69. GOBJMBN_CLIQSET & _cliqset;
  70. // Vector of nodes pointers in total ordering
  71. VNDCQINFO _vndcqInfo;
  72. // Vector of vectors of node pointers (clique members)
  73. VVPGNODEMBN _vvpgnd;
  74. // Clique ordering;
  75. // < 0 ==> subsumed into another clique;
  76. // 0 <= i < INT_MAX ==> ordering into _viOrdered;
  77. // == INT_MAX ==> deleted or merged
  78. VINT _viOrder;
  79. // Parent clique indicies by clique index
  80. VINT _viParent;
  81. // Clique indicies as they are ordered
  82. VINT _viOrdered;
  83. // Number of nodes in common with most common clique;
  84. // indexed by absolute clique index.
  85. VINT _viCNodesCommon;
  86. // Contains ordered clique index of most common clique;
  87. // indexed by absolute clique index.
  88. VINT _viICliqCommon;
  89. // Ordered parent index of each ordered clique
  90. VINT _viParentOrdered;
  91. // Topological level of each ordered clique
  92. VINT _viTopLevelOrdered;
  93. // Array of pointers to cliques created
  94. VPGOBJMBN_CLIQUE _vpclq;
  95. // Elimination index
  96. int _iElimIndex;
  97. // Number of trees created
  98. int _cTrees;
  99. };
  100. #endif
  101. // End Of JTREEWORK.H