Beispiel #1
0
void FibHeap::Print(FibHeapNode *Tree, FibHeapNode *theParent)
{
  FibHeapNode* Temp = NULL;
  
  if (Tree == NULL) Tree = MinRoot;
  
  Temp = Tree;
  do {
    if (Temp->Left == NULL)
      mexPrintf( "(Left is NULL)" );
    Temp->Print();
    if (Temp->Parent != theParent)
      mexPrintf("(Parent is incorrect)" );
    if (Temp->Right == NULL)
      mexPrintf( "(Right is NULL)" );
    else if (Temp->Right->Left != Temp)
      mexPrintf( "(Error in left link left) ->" );
    else mexPrintf( " <-> " );
    
    Temp = Temp->Right;
    
    /*
    if (kbhit() && getch() == 27)
    {
      cout << "Hit a key to resume or ESC to break\n";
      if (getch() == 27)
        break;
    }
     */
  } while (Temp != NULL && Temp != Tree);
  mexPrintf( "\n" );
  
  Temp = Tree;
  do {
    mexPrintf( "Children of " );
    Temp->Print();
    mexPrintf( ": " );
    if (Temp->Child == NULL)
      mexPrintf( "NONE\n" );
    else Print(Temp->Child, Temp);
    Temp = Temp->Right;
  } while (Temp!=NULL && Temp != Tree);
  
  if (theParent == NULL)
  {
    char ch;
    
    mexPrintf( "\n\n\n" );
    cin >> ch;
  }
Beispiel #2
0
void FibHeap::Print(FibHeapNode *Tree, FibHeapNode *theParent)
{
FibHeapNode* Temp = NULL;

     if (Tree == NULL) Tree = MinRoot;

     Temp = Tree;
     do {
		if (Temp->Left == NULL)
		    cout << "(Left is NULL)";
		Temp->Print();
		if (Temp->Parent != theParent)
		    cout << "(Parent is incorrect)";
		if (Temp->Right == NULL)
		     cout << "(Right is NULL)";
		else if (Temp->Right->Left != Temp)
			 cout << "(Error in left link left) ->";
		else cout << " <-> ";

		Temp = Temp->Right;

		if (kbhit() && getch() == 27)
		{
			cout << "Hit a key to resume or ESC to break\n";
			if (getch() == 27)
                break;
		}
     } while (Temp != NULL && Temp != Tree);
     cout << '\n';

     Temp = Tree;
     do {
	cout << "Children of ";
	Temp->Print();
	cout << ": ";
	if (Temp->Child == NULL)
	     cout << "NONE\n";
        else Print(Temp->Child, Temp);
	Temp = Temp->Right;
     } while (Temp!=NULL && Temp != Tree);

     if (theParent == NULL)
     {
     char ch;

	 cout << "Done Printing.  Hit a key.\n";
         cin >> ch;
     }