当前位置: 首页>>代码示例>>C++>>正文


C++ TreeType类代码示例

本文整理汇总了C++中TreeType的典型用法代码示例。如果您正苦于以下问题:C++ TreeType类的具体用法?C++ TreeType怎么用?C++ TreeType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TreeType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CleanTree

void CleanTree(TreeType& node)
{
  node.Stat().LastDistance() = 0.0;

  for (size_t i = 0; i < node.NumChildren(); ++i)
    CleanTree(node.Child(i));
}
开发者ID:Jacksonlark,项目名称:mlpack,代码行数:7,代码来源:range_search_test.cpp

示例2: pruneTree

void CARTTrainer::pruneTree(TreeType & tree){

	//Calculate g of all the nodes
	measureStrength(tree, 0, 0);

	//Find the lowest g of the internal nodes
	double g = std::numeric_limits<double>::max();
	for(std::size_t i = 0; i != tree.size(); i++){
		if(tree[i].leftNodeId > 0 && tree[i].g < g){
			//Update g
			g = tree[i].g;
		}
	}
	//Prune the nodes with lowest g and make them terminal
	for(std::size_t i=0; i != tree.size(); i++){
		//Make the internal nodes with the smallest g terminal nodes and prune their children!
		if( tree[i].leftNodeId > 0 && tree[i].g == g){
			// pruneNode(tree, tree[i].leftNodeId);
			// pruneNode(tree, tree[i].rightNodeId);
			// //Make the node terminal
			tree[i].leftNodeId = 0;
			tree[i].rightNodeId = 0;
		}
	}
}
开发者ID:jakobht,项目名称:Shark,代码行数:25,代码来源:CARTTrainer.cpp

示例3: DTBStat

 DTBStat(const TreeType& node) :
     maxNeighborDistance(DBL_MAX),
     minNeighborDistance(DBL_MAX),
     bound(DBL_MAX),
     componentMembership(
         ((node.NumPoints() == 1) && (node.NumChildren() == 0)) ?
           node.Point(0) : -1) { }
开发者ID:shenzebang,项目名称:mlpack,代码行数:7,代码来源:dtb_stat.hpp

示例4: CheckHierarchy

void CheckHierarchy(const TreeType& tree)
{
  for (size_t i = 0; i < tree.NumChildren(); i++)
  {
    BOOST_REQUIRE_EQUAL(&tree, tree.Child(i).Parent());
    CheckHierarchy(tree.Child(i));
  }
}
开发者ID:darcyliu,项目名称:mlpack,代码行数:8,代码来源:rectangle_tree_test.cpp

示例5: CalculateBound

double FastMKSRules<KernelType, TreeType>::Rescore(TreeType& queryNode,
        TreeType& /*referenceNode*/,
        const double oldScore) const
{
    queryNode.Stat().Bound() = CalculateBound(queryNode);
    const double bestKernel = queryNode.Stat().Bound();

    return ((1.0 / oldScore) > bestKernel) ? oldScore : DBL_MAX;
}
开发者ID:GABowers,项目名称:MinGW_libs,代码行数:9,代码来源:fastmks_rules_impl.hpp

示例6: FastMKSStat

  FastMKSStat(const TreeType& node) :
      bound(-DBL_MAX),
      lastKernel(0.0),
      lastKernelNode(NULL)
  {
    // Do we have to calculate the centroid?
    if (tree::TreeTraits<TreeType>::FirstPointIsCentroid)
    {
      // If this type of tree has self-children, then maybe the evaluation is
      // already done.  These statistics are built bottom-up, so the child stat
      // should already be done.
      if ((tree::TreeTraits<TreeType>::HasSelfChildren) &&
          (node.NumChildren() > 0) &&
          (node.Point(0) == node.Child(0).Point(0)))
      {
        selfKernel = node.Child(0).Stat().SelfKernel();
      }
      else
      {
        selfKernel = sqrt(node.Metric().Kernel().Evaluate(
            node.Dataset().col(node.Point(0)),
            node.Dataset().col(node.Point(0))));
      }
    }
    else
    {
      // Calculate the centroid.
      arma::vec center;
      node.Center(center);

      selfKernel = sqrt(node.Metric().Kernel().Evaluate(center, center));
    }
  }
开发者ID:YaweiZhao,项目名称:mlpack,代码行数:33,代码来源:fastmks_stat.hpp

示例7: GetSplitPolicy

  static int GetSplitPolicy(const TreeType& child,
                            const size_t axis,
                            const typename TreeType::ElemType cut)
  {
    if (child.Bound()[axis].Hi() <= cut)
      return AssignToFirstTree;
    else if (child.Bound()[axis].Lo() >= cut)
      return AssignToSecondTree;

    return SplitRequired;
  }
开发者ID:YaweiZhao,项目名称:mlpack,代码行数:11,代码来源:r_plus_tree_split_policy.hpp

示例8: pruneNode

/*
	Removes branch with root node id nodeId, incl. the node itself
*/
void CARTTrainer::pruneNode(TreeType & tree, std::size_t nodeId){
	std::size_t i = findNode(tree,nodeId);

	if(tree[i].leftNodeId>0){
		//Prune left branch
		pruneNode(tree, tree[i].leftNodeId);
		//Prune right branch
		pruneNode(tree, tree[i].rightNodeId);
	}
	//Remove node
	tree.erase(tree.begin()+i);
}
开发者ID:jakobht,项目名称:Shark,代码行数:15,代码来源:CARTTrainer.cpp

示例9: BaseCase

double RangeSearchRules<MetricType, TreeType>::Score(const size_t queryIndex,
                                                     TreeType& referenceNode)
{
  // We must get the minimum and maximum distances and store them in this
  // object.
  math::Range distances;

  if (tree::TreeTraits<TreeType>::FirstPointIsCentroid)
  {
    // In this situation, we calculate the base case.  So we should check to be
    // sure we haven't already done that.
    double baseCase;
    if (tree::TreeTraits<TreeType>::HasSelfChildren &&
        (referenceNode.Parent() != NULL) &&
        (referenceNode.Point(0) == referenceNode.Parent()->Point(0)))
    {
      // If the tree has self-children and this is a self-child, the base case
      // was already calculated.
      baseCase = referenceNode.Parent()->Stat().LastDistance();
      lastQueryIndex = queryIndex;
      lastReferenceIndex = referenceNode.Point(0);
    }
    else
    {
      // We must calculate the base case by hand.
      baseCase = BaseCase(queryIndex, referenceNode.Point(0));
    }

    // This may be possibly loose for non-ball bound trees.
    distances.Lo() = baseCase - referenceNode.FurthestDescendantDistance();
    distances.Hi() = baseCase + referenceNode.FurthestDescendantDistance();

    // Update last distance calculation.
    referenceNode.Stat().LastDistance() = baseCase;
  }
  else
  {
    distances = referenceNode.RangeDistance(querySet.unsafe_col(queryIndex));
  }

  // If the ranges do not overlap, prune this node.
  if (!distances.Contains(range))
    return DBL_MAX;

  // In this case, all of the points in the reference node will be part of the
  // results.
  if ((distances.Lo() >= range.Lo()) && (distances.Hi() <= range.Hi()))
  {
    AddResult(queryIndex, referenceNode);
    return DBL_MAX; // We don't need to go any deeper.
  }

  // Otherwise the score doesn't matter.  Recursion order is irrelevant in
  // range search.
  return 0.0;
}
开发者ID:gbkedar,项目名称:mlpack-gatech,代码行数:56,代码来源:range_search_rules_impl.hpp

示例10: UpdateAuxiliaryInfo

bool HilbertRTreeAuxiliaryInformation<TreeType, HilbertValueType>::
UpdateAuxiliaryInfo(TreeType* node)
{
  if (node->IsLeaf())  //  Should already be updated
    return true;

  TreeType* child = node->Children()[node->NumChildren() - 1];
  if (hilbertValue.CompareWith(child->AuxiliaryInfo().hilbertValue()) < 0)
  {
    hilbertValue.Copy(node,child);
    return true;
  }
  return false;
}
开发者ID:caomw,项目名称:mlpack,代码行数:14,代码来源:hilbert_r_tree_auxiliary_information_impl.hpp

示例11: SearchTree

void SearchTree(TreeType<T>& tree)
{
	T input;
	cout << "Enter item to search: ";
	cin >> input;
	tree.SearchItem(input);
}
开发者ID:barovig,项目名称:ComputerScience,代码行数:7,代码来源:CA_1A.cpp

示例12: DeleteFromTree

void DeleteFromTree(TreeType<T>& tree)
{
	T input;
	cout << "Enter item to delete: ";
	cin >> input;
	tree.DeleteItem(input);
}
开发者ID:barovig,项目名称:ComputerScience,代码行数:7,代码来源:CA_1A.cpp

示例13: InsertItem

void InsertItem(TreeType<T>& tree)
{
	cout << "Enter number: ";
	T num;
	cin >> num;
	tree.InsertItem(num);
}
开发者ID:barovig,项目名称:ComputerScience,代码行数:7,代码来源:CA_1A.cpp

示例14: GetMaxLevel

int GetMaxLevel(const TreeType& tree)
{
  int max = 1;
  if (!tree.IsLeaf())
  {
    int m = 0;
    for (size_t i = 0; i < tree.NumChildren(); i++)
    {
      int n = GetMaxLevel(*tree.Children()[i]);
      if (n > m)
        m = n;
    }
    max += m;
  }

  return max;
}
开发者ID:darcyliu,项目名称:mlpack,代码行数:17,代码来源:rectangle_tree_test.cpp

示例15: GetMinLevel

int GetMinLevel(const TreeType& tree)
{
  int min = 1;
  if (!tree.IsLeaf())
  {
    int m = INT_MAX;
    for (size_t i = 0; i < tree.NumChildren(); i++)
    {
      int n = GetMinLevel(*tree.Children()[i]);
      if (n < m)
        m = n;
    }
    min += m;
  }

  return min;
}
开发者ID:darcyliu,项目名称:mlpack,代码行数:17,代码来源:rectangle_tree_test.cpp


注:本文中的TreeType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。