本文整理汇总了C#中INode.Size方法的典型用法代码示例。如果您正苦于以下问题:C# INode.Size方法的具体用法?C# INode.Size怎么用?C# INode.Size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INode
的用法示例。
在下文中一共展示了INode.Size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Cluster
/// <summary>
/// Clusters Two INodes together, sets new root/parent/left and right edges
/// </summary>
/// <param name="left"> Node on the left </param>
/// <param name="right"> Node on the Right </param>
/// <param name="match"> Inverted or Not Inverted </param>
/// <param name="matchData"> Optional MatchData variable, store clustering information </param>
public Cluster(INode left, INode right, Match match = Match.NonInverted, MatchData matchData = null)
{
if (match == Match.Impossible)
{
throw new ArgumentException("Match is apparently impossible why are you trying?");
}
// Now Build the new nodes
_left = left;
_right = right;
_matchData = matchData;
_size = left.Size() + right.Size();
_leftedge = left.LeftEdge();
_rightedge = right.RightEdge();
// Set the parents accordingly
left.Parent(this);
right.Parent(this);
_parent = null;
// change the roots
_left.Root(this);
_right.Root(this);
// Update Count
Id = _count++;
}
示例2: PrintFlatTree
public static void PrintFlatTree(INode root)
{
var list = new List<Shred>(root.Size());
root.Flatten(list);
list.ForEach(item => Console.Write(item.Id + " , "));
Console.WriteLine("");
}
示例3: CalculateSize
private static int CalculateSize(INode node)
{
if (node.Left() != null && node.Right() != null && !node.IsLeaf())
{
return CalculateSize(node.Left()) + CalculateSize(node.Right());
;
}
if (node.Left() == null && node.Right() == null && node.IsLeaf())
{
return node.Size();
}
throw new Exception("Badly Constructed INode Tree");
}
示例4: IsMirror
private static bool IsMirror(INode reg, INode rev)
{
if (reg.IsLeaf() ^ rev.IsLeaf())
{
throw new Exception("Mirrored nodes are not at the same height");
}
if (reg.IsLeaf() && rev.IsLeaf())
{
Assert.IsTrue(reg.Size() == rev.Size());
Assert.IsTrue(reg.Leaf().Orientation == Enumeration.Opposite(rev.Leaf().Orientation));
Assert.IsTrue(reg.LeftEdge().Direction == Enumeration.Opposite(rev.RightEdge().Direction));
return true;
}
return IsMirror(reg.Left(), rev.Right()) && IsMirror(reg.Right(), rev.Left());
}