本文整理汇总了C#中GraphToDSCompiler.Node.GetChildren方法的典型用法代码示例。如果您正苦于以下问题:C# Node.GetChildren方法的具体用法?C# Node.GetChildren怎么用?C# Node.GetChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphToDSCompiler.Node
的用法示例。
在下文中一共展示了Node.GetChildren方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DFSVisit
static void DFSVisit(Node node, Dictionary<Node, int> nodeStateMap, List<Node> list)
{
nodeStateMap.Add(node, VISITING);
List<Node> nodes = node.GetChildren();
IEnumerable iter = nodes;
foreach (Node nodeI in iter)
{
if (IsNotVisited(nodeI, nodeStateMap))
DFSVisit(nodeI, nodeStateMap, list);
}
nodeStateMap[node] = VISITED;
list.Add(node);
}
示例2: DFSVisit
/// <summary>
/// Returns false if a depth-first search of Graph yields no back edges.
/// If back edges found then return true and update cycleStack.
/// </summary>
/// <param name="node"></param>
/// <param name="nodeStateMap"></param>
/// <param name="cycleStack"></param>
/// <returns></returns>
public static Boolean DFSVisit(Node node, Dictionary<Node, int> nodeStateMap, List<Node> cycleStack)
{
cycleStack.Add(node);
nodeStateMap.Add(node, visiting);
List<Node> nodes = node.GetChildren();
IEnumerable iter = nodes;
foreach (Node nodeI in iter)
{
if (IsNotVisited(nodeI, nodeStateMap))
{
if (DFSVisit(nodeI, nodeStateMap, cycleStack)) return true;
}
else if (IsVisiting(nodeI, nodeStateMap))
{
cycleStack.Insert(0,node);
return true;
}
}
nodeStateMap[node] = visited;
cycleStack.RemoveAt(0);
return false;
}
示例3: RemoveNode
/// <summary>
/// Removes the node passed as parameter from the graph(represented using NodeMap)
/// </summary>
/// <param name="rem"></param>
/// <returns></returns>
public bool RemoveNode(Node rem)
{
if (nodeMap.ContainsKey(rem.Guid))
{
IEnumerable iter = rem.GetChildren();
foreach (Node child in iter)
{
child.RemoveParent(rem);
}
iter = rem.GetParents();
foreach (Node dad in iter)
{
dad.RemoveChild(rem);
}
nodeMap.Remove(rem.Guid);
nodeList.Remove(rem);
return true;
}
return false;
}
示例4: RemoveAllEdges
/// <summary>
/// Remove all edges from or to the node passed as parameter.
/// </summary>
/// <param name="rem"></param>
/// <returns></returns>
public bool RemoveAllEdges(Node rem)
{
if (nodeMap.ContainsKey(rem.Guid))
{
IEnumerable iter = rem.GetChildren();
foreach (Node child in iter)
{
rem.RemoveChild(child);
child.RemoveParent(rem);
}
iter = rem.GetParents();
foreach (Node dad in iter)
{
rem.RemoveChild(dad);
dad.RemoveChild(rem);
}
return true;
}
return false;
}