本文整理汇总了C#中ISymbolicExpressionTree.IterateNodesBreadth方法的典型用法代码示例。如果您正苦于以下问题:C# ISymbolicExpressionTree.IterateNodesBreadth方法的具体用法?C# ISymbolicExpressionTree.IterateNodesBreadth怎么用?C# ISymbolicExpressionTree.IterateNodesBreadth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISymbolicExpressionTree
的用法示例。
在下文中一共展示了ISymbolicExpressionTree.IterateNodesBreadth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyBacktransformation
private void ApplyBacktransformation(ITransformation transformation, ISymbolicExpressionTree symbolicExpressionTree, string targetVariable) {
if (transformation.Column != targetVariable) {
var variableNodes = symbolicExpressionTree.IterateNodesBreadth()
.OfType<VariableTreeNode>()
.Where(n => n.VariableName == transformation.Column);
ApplyRegularBacktransformation(transformation, variableNodes);
} else if (!(transformation is CopyColumnTransformation)) {
ApplyInverseBacktransformation(transformation, symbolicExpressionTree);
}
}
示例2: Format
public string Format(ISymbolicExpressionTree symbolicExpressionTree) {
var root = symbolicExpressionTree.Root;
var actualRoot = root.SubtreeCount == 0 ? root.GetSubtree(0) : root;
var nodeCoordinates = layoutEngine.CalculateLayout(actualRoot).ToDictionary(n => n.Content, n => new PointF(n.X, n.Y));
var sb = new StringBuilder();
var nl = Environment.NewLine;
double ws = 1;
double hs = 0.7;
sb.Append("\\documentclass[class=minimal,border=0pt]{standalone}" + nl +
"\\usepackage{tikz}" + nl +
"\\begin{document}" + nl +
"\\begin{tikzpicture}" + nl +
"\\def\\ws{1}" + nl +
"\\def\\hs{0.7}" + nl);
var nodeIndices = new Dictionary<ISymbolicExpressionTreeNode, int>();
var nodes = symbolicExpressionTree.IterateNodesBreadth().ToList();
for (int i = 0; i < nodes.Count; ++i) {
var node = nodes[i];
nodeIndices.Add(node, i);
var coord = nodeCoordinates[node];
var nodeName = symbolNameMap.ContainsKey(node.Symbol.Name) ? symbolNameMap[node.Symbol.Name] : node.ToString();
sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "\\node ({0}) at (\\ws*{1},\\hs*{2}) {{{3}}};", i, ws * coord.X, -hs * coord.Y, EscapeLatexString(nodeName)));
}
for (int i = 0; i < nodes.Count; ++i) {
foreach (var s in nodes[i].Subtrees) {
sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "\\draw ({0}) -- ({1});", i, nodeIndices[s]));
}
}
sb.Append("\\end{tikzpicture}" + nl +
"\\end{document}" + nl);
return sb.ToString();
}