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


C++ NodePtr::GetSibling方法代码示例

本文整理汇总了C++中NodePtr::GetSibling方法的典型用法代码示例。如果您正苦于以下问题:C++ NodePtr::GetSibling方法的具体用法?C++ NodePtr::GetSibling怎么用?C++ NodePtr::GetSibling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NodePtr的用法示例。


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

示例1: copyTraverse

//------------------------------------------------------------------------------
// This code needs Tree to be a friend of Node
void Tree::copyTraverse (NodePtr p1, NodePtr &p2) const
{
	if (p1)
	{
		p2 = NewNode ();
		p1->Copy (p2);
		
		// Note the call to p2->child, not p2->GetChild(). Calling the field
		// is essential because calling GetChild merely passes a temporary
		// copy of the child, hence we are not actually creating a child of p2.
		// We can access child directly by making Tree a friend of Node (see
		// TreeLib.h).
		copyTraverse (p1->GetChild(), p2->Child);
		if (p2->GetChild())
			p2->GetChild()->SetAnc (p2);
		
		// Ensure we don't copy RootedAt sibling. If the sibling is NULL then
		// we won't anyway, but this line ensures this for all cases.
		if (p1 != CurNode)
			copyTraverse (p1->GetSibling(), p2->Sib);  // note sib
		if (p2->GetChild ())
		{
			NodePtr q = p2->GetChild()->GetSibling();
			while (q)
			{
				q->SetAnc (p2);
				q = q->GetSibling();
			}
		}
	}
}
开发者ID:thanhleviet,项目名称:brownie,代码行数:33,代码来源:TreeLib.cpp

示例2: AddNodeBelow

//------------------------------------------------------------------------------
// Add Node below Below. Doesn't update any clusters, weights, etc.
void Tree::AddNodeBelow (NodePtr Node, NodePtr Below)
{
	NodePtr Ancestor = NewNode ();
	Ancestor->SetChild (Node);
	Node->SetAnc (Ancestor);
	NodePtr q = Below->GetAnc ();
	Internals++;
	if (Node->IsLeaf())
		Leaves++;
	if (q == NULL || Below == q->GetChild())
	{
		Node->SetSibling (Below);
		Ancestor->SetAnc (q);
		Ancestor->SetSibling (Below->GetSibling());
		Below->SetSibling (NULL);
		Below->SetAnc (Ancestor);
		if (q == NULL)
			Root = Ancestor;
		else
			q->SetChild (Ancestor);
	}
	else
	{
		// Get left sibling of Below
		NodePtr r = Below->LeftSiblingOf();
		while (Below != r->GetSibling())
			r = r->GetSibling();
		Node->SetSibling (Below);
		Ancestor->SetAnc (q);
		Ancestor->SetSibling (Below->GetSibling());
		Below->SetSibling (NULL);
		Below->SetAnc (Ancestor);
		r->SetSibling (Ancestor);
	}
}
开发者ID:thanhleviet,项目名称:brownie,代码行数:37,代码来源:TreeLib.cpp

示例3: drawAsTextTraverse

//------------------------------------------------------------------------------
void Tree::drawAsTextTraverse (NodePtr p)
{
	if (p)
	{
		drawAsTextTraverse (p->GetChild ());
		if (p->IsLeaf ())
			drawPendantEdge (p);
		if (p->GetSibling ())
			drawInteriorEdge (p);
		drawAsTextTraverse (p->GetSibling ());
	}
}
开发者ID:thanhleviet,项目名称:brownie,代码行数:13,代码来源:TreeLib.cpp

示例4: traversenoquote

//Added by BCO
//------------------------------------------------------------------------------
void Tree::traversenoquote (NodePtr p)
{
	
	if (p)
	{
		if (p->IsLeaf())
		{
			for (int i=0; i<(NEXUSString (p->GetLabel())).length(); i++) {
				if ((NEXUSString (p->GetLabel()))[i]!= '\'') {
					*treeStream <<(NEXUSString (p->GetLabel()))[i];
				}
			}
			//*treeStream<<NEXUSString (p->GetLabel());
			if (EdgeLengths)
			{
				*treeStream << ':' << p->GetEdgeLength ();
			}
		}
		else
		{
			*treeStream << "(";
		}
		
		traversenoquote (p->GetChild());
		if (p->GetSibling())
		{
			*treeStream << ",";
		}
		else
		{
			if (p != Root)
			{
				*treeStream << ")";
				// 29/3/96
				if ((p->GetAnc()->GetLabel() != "") && InternalLabels)
				{
					*treeStream <<  NEXUSString (p->GetAnc()->GetLabel ()) ; //here's the change from traverse
				}
				if (EdgeLengths && (p->GetAnc () != Root))
				{
					*treeStream << ':' << p->GetAnc()->GetEdgeLength ();
				}
			}
		}
		traversenoquote (p->GetSibling());
	}
	
}
开发者ID:thanhleviet,项目名称:brownie,代码行数:50,代码来源:TreeLib.cpp

示例5: makeNodeList

//------------------------------------------------------------------------------
void Tree::makeNodeList (NodePtr p)
{
	if (p)
	{
		makeNodeList (p->GetChild ());
		makeNodeList (p->GetSibling ());
		if (p->IsLeaf())
		{
			int leafnumberposition=p->GetLeafNumber()-1;//modified by BCO
			string plabel=p->GetLabel(); //modified by BCO
			LeafList[plabel] = leafnumberposition; //modified by BCO
			assert((Leaves+Internals)>leafnumberposition);
			Nodes[leafnumberposition] = p; //modified by BCO
			p->SetIndex (leafnumberposition); //modified by BCO
		}
		else
		{
			Nodes[count] = p;
			p->SetIndex (count);
			count++;
		}
		if (p != Root)
		{
		}
	}
}
开发者ID:thanhleviet,项目名称:brownie,代码行数:27,代码来源:TreeLib.cpp

示例6: buildtraverse

//------------------------------------------------------------------------------
// Fill in weight, degree, etc.
void Tree::buildtraverse (NodePtr p)
{
	if (p)
	{
		p->SetWeight (0);
		/*p->SetModelCategory(vector<double>(1,1.0)); //added by BCO
		p->SetStateOrder(vector<int>(1,0)); //Added by BCO
		p->SetStateTimes(vector<double>(1,0.0)); //Added by BCO*/
		p->SetDegree (0);
		buildtraverse (p->GetChild ());
		buildtraverse (p->GetSibling ());
		if (p->IsLeaf())
		{
			Leaves++;
			p->SetWeight (1);
			/*p->SetModelCategory(vector<double>(1,1.0)); //Added by BCO
			p->SetStateOrder(vector<int>(1,0)); //Added by BCO
			p->SetStateTimes(vector<double>(1,0.0)); //Added by BCO*/
			
		}
		else
		{
			Internals++;
		}
		if (p != Root)
		{
			p->GetAnc()->AddWeight (p->GetWeight());
			p->GetAnc()->IncrementDegree();
		}
	}
}
开发者ID:thanhleviet,项目名称:brownie,代码行数:33,代码来源:TreeLib.cpp

示例7: markNodes

//------------------------------------------------------------------------------
void Tree::markNodes(NodePtr p, bool on)
{
	if (p)
	{
		p->SetMarked (on);
		markNodes (p->GetChild(), on);
		markNodes (p->GetSibling(), on);
	}
}
开发者ID:thanhleviet,项目名称:brownie,代码行数:10,代码来源:TreeLib.cpp

示例8: deletetraverse

//------------------------------------------------------------------------------
void Tree::deletetraverse (NodePtr p)
{
	if (p)
	{
		deletetraverse (p->GetChild());
		deletetraverse (p->GetSibling());
		delete p;
	}
}
开发者ID:thanhleviet,项目名称:brownie,代码行数:10,代码来源:TreeLib.cpp

示例9: traverse

//------------------------------------------------------------------------------
void Tree::traverse (NodePtr p)
{
	
	if (p)
	{
		if (p->IsLeaf())
		{
			*treeStream << NEXUSString (p->GetLabel());
			
			if (EdgeLengths)
			{
				*treeStream << ':' << p->GetEdgeLength ();
			}
		}
		else
		{
			*treeStream << "(";
		}
		
		traverse (p->GetChild());
		if (p->GetSibling())
		{
			*treeStream << ",";
		}
		else
		{
			if (p != Root)
			{
				*treeStream << ")";
				// 29/3/96
				if ((p->GetAnc()->GetLabel() != "") && InternalLabels)
				{
					*treeStream << '\'' << NEXUSString (p->GetAnc()->GetLabel ()) << '\'';
				}
				if (EdgeLengths && (p->GetAnc () != Root))
				{
					*treeStream << ':' << p->GetAnc()->GetEdgeLength ();
				}
			}
		}
		traverse (p->GetSibling());
	}
	
}
开发者ID:thanhleviet,项目名称:brownie,代码行数:45,代码来源:TreeLib.cpp

示例10: getNodeHeights

//------------------------------------------------------------------------------
void Tree::getNodeHeights(NodePtr p)
{
	if (p)
	{
		p->SetHeight (Leaves - p->GetWeight ());
		if (p->GetHeight() > MaxHeight)
			MaxHeight = p->GetHeight();
		getNodeHeights (p->GetChild());
		getNodeHeights (p->GetSibling());
	}
}
开发者ID:thanhleviet,项目名称:brownie,代码行数:12,代码来源:TreeLib.cpp

示例11: drawPendantEdge

//------------------------------------------------------------------------------
void Tree::drawPendantEdge (NodePtr p)
{
	NodePtr q = p->GetAnc();
	if (q == NULL)
	{
		// Handle the degenerate case of a tree with a single leaf
		Line = (char) HBAR;
		drawLine (p);	
	}
	else
	{
		int start = q->GetHeight();
		int stop = p->GetHeight();
		char	symbol;
		
		// Draw line between p and its ancestor
		int i;
		for (i = start + 1; i <= stop; i++)
			Line[i] = (char)HBAR;      // €
		
		// Find appropriate symbol for link to ancestor
		if (p == q->GetChild())
		{
			symbol = (char)LEFT;       // ò
		}
		else
		{
			// p is a sibling
			if (p->GetSibling())
				symbol = (char)SIB;     // Ì
			else symbol = (char)RIGHT; // Ë
		}
		Line[start] = symbol;
		
		// Fill in ancestors
		fillInAncestors (p);
		
		// Terminate line
		Line[stop + 1] = '\0';
		
		
		drawLine (p);
		/*		// Output line and taxon name
			*treeStream << Line.c_str() << " " << p->GetLabel ()
			//			<< "h=" << p->GetHeight() << " w= "
			//			<< p->GetWeight()
			<<endl;
		*/
		
		// Clear the line for the next pass
		for (i = 0; i < (Leaves + 2); i++) // to do: get a better limit for this
			Line[i] = ' ';
	}
}
开发者ID:thanhleviet,项目名称:brownie,代码行数:55,代码来源:TreeLib.cpp

示例12: getNodeDepth

//------------------------------------------------------------------------------
// Compute node depth (i.e, height above root). Based on COMPONENT 2.0 code, 
// assumes count is set to 0 prior to calling code
void Tree::getNodeDepth(NodePtr p)
{
	if (p)
    {
		
    	p->SetDepth (count);
    	count++;
        getNodeDepth (p->GetChild());
		count--;
        getNodeDepth (p->GetSibling());
    }
}
开发者ID:thanhleviet,项目名称:brownie,代码行数:15,代码来源:TreeLib.cpp

示例13: SortDescendants

//------------------------------------------------------------------------------
void TreeOrder::SortDescendants (NodePtr node)
{
	NodePtr head = node->GetChild ();
	NodePtr tail = head;
	while (tail->GetSibling () != NULL)
	{
		NodePtr p = tail->GetSibling ();
		if (MustSwap (head, p))
		{
			tail->SetSibling (p->GetSibling ());
			p->SetSibling (head);
			head = p;
			p->GetAnc()->SetChild (p);
		}
		else
		{
			NodePtr q = head;
			NodePtr r = q->GetSibling ();
			while (MustSwap (p, r))
			{
				q = r;
				r = q->GetSibling ();
			}
			if (p == r)
				tail = p;
			else
			{
				tail->SetSibling (p->GetSibling ());
				p->SetSibling (r);
				q->SetSibling (p);
			}
		}
	}
}
开发者ID:bomeara,项目名称:omearatenure,代码行数:35,代码来源:treeorder.cpp

示例14: getPathLengths

//------------------------------------------------------------------------------
// Compute nodal heights based on path length from root, and store maximum
// value in plot.maxheight. Used by drawing routines.
void Tree::getPathLengths (NodePtr p)
{
	if (p)
	{
		if (p != Root)
		{
			float l = p->GetEdgeLength();
			if (l < 0.000001) // suppress negative branch lengths
				l = 0.0;
			p->SetPathLength (p->GetAnc()->GetPathLength() + l);
		}
		if (p->GetPathLength() > MaxPathLength)
			MaxPathLength = p->GetPathLength();
		getPathLengths (p->GetChild());
		getPathLengths (p->GetSibling());
	}
}
开发者ID:thanhleviet,项目名称:brownie,代码行数:20,代码来源:TreeLib.cpp

示例15: CalcInternal

//------------------------------------------------------------------------------
void CircleTreeDrawer::CalcInternal (Node *p)
{
	double left_angle = node_angle[p->GetChild()];
    double right_angle = node_angle[p->GetChild()->GetRightMostSibling()];
   	node_angle[p] = left_angle + (right_angle - left_angle)/2.0;
    node_radius[p] = nodeGap * (double)(maxDepth - p->GetDepth());

    node_coordinates[p].x = node_radius[p] * cos (node_angle[p]);
    node_coordinates[p].y = node_radius[p] * sin (node_angle[p]);

    NodePtr q = p->GetChild();
    while (q)
    {
    	point pt;
        node_backarc[q] = pt;
    	node_backarc[q].x = node_radius[p] * cos (node_angle[q]);
        node_backarc[q].y = node_radius[p] * sin (node_angle[q]);
        q = q->GetSibling();
    }
}
开发者ID:bomeara,项目名称:omearatenure,代码行数:21,代码来源:treedrawer.cpp


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