Пример #1
0
void clusclus::GetKids(int k, int* Tnums, int* pickedup, int* kids) 
{
	int   i = 0, j = 0, k1, k2;

	if (k < num_samples)                        //if node number is a leaf
	{     
		while (j == 0) 
		{                        //find first open position in pickedup
			if (kids[i] == -1) 
			{
				j = 1;
				kids[i] = k;
				pickedup[i] = k;   //may not need this
			}
			i++;
		}
	}
	else                     //if node number is not a leaf
	{                  
		for (j = 0; j < num_samples-1; j++) 
		{
			if (Tnums[j] == k) i = j;
		}                     //find index of k in Tnums
		k1 = (int)treedata[i][0];
		k2 = (int)treedata[i][1];
		GetKids(k1, Tnums, pickedup, kids); //pick up kids from node k1
		GetKids(k2, Tnums, kids, kids);     //pick up kids from node k2
	}
	return;
}
Пример #2
0
NS_IMETHODIMP nsAccessibleTreeWalker::GetFirstChild()
{
  mState.accessible = nsnull;
  if (mState.isHidden || !mState.domNode) {
    return NS_ERROR_FAILURE;
  }

  nsCOMPtr<nsIDOMNode> parent(mState.domNode);
  GetKids(parent); // Side effects change our state (mState)

  // Recursive loop: depth first search for first accessible child
  while (mState.domNode) {
    if ((mState.domNode != parent && GetAccessible()) || NS_SUCCEEDED(GetFirstChild()))
      return NS_OK;
    UpdateFrame(PR_FALSE);
    GetNextDOMNode();
  }

  PopState();  // Return to previous state
  return NS_ERROR_FAILURE;
}
Пример #3
0
void clusclus::GetOptimalLeafOrderD() 
{
	int  i, k;
	int* Tnums;
	int* pickedup;

	Tnums = new int[num_samples - 1];
	pickedup = new int[num_samples];

	//Initialize variables
	k = 2*(num_samples-1);                                //maximum cluster number
	for (i = 0; i < num_samples-1; i++) Tnums[i] = num_samples+i;
	for (i = 0; i < num_samples; i++) pickedup[i] = -1;
	for (i = 0; i < num_samples; i++) optimalleaforder[i] = -1;

	//Get kids
	GetKids(k, Tnums, pickedup, optimalleaforder);

	delete Tnums;
	delete pickedup;

	return;
}