本文整理汇总了C#中IGraphBuilder.Create方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphBuilder.Create方法的具体用法?C# IGraphBuilder.Create怎么用?C# IGraphBuilder.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraphBuilder
的用法示例。
在下文中一共展示了IGraphBuilder.Create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Split
/// <summary>
/// Divides the supplied graph to its connected subgraphs.
/// </summary>
public static IGraph[] Split(IGraph initial, IGraphBuilder builder)
{
// A list with the nodes awaiting to be processed
NodeCollection nodes = initial.Nodes.Clone() as NodeCollection;
// A list with the subgraphs
IGraph subgraph = null;
ArrayList subgraphs = new ArrayList();
while (nodes.Count > 0)
{
INode node = nodes[0];
nodes.RemoveAt(0);
subgraph = builder.Create();
subgraph.Nodes.Add(node);
int i = 0;
while (i < subgraph.Nodes.Count)
{
node = subgraph.Nodes[i];
foreach (ILink link in node.InLinks)
{
if (!subgraph.Nodes.Contains(link.Origin))
{
subgraph.Nodes.Add(link.Origin);
nodes.Remove(link.Origin);
}
if (!subgraph.Links.Contains(link))
subgraph.Links.Add(link);
}
foreach (ILink link in node.OutLinks)
{
if (!subgraph.Nodes.Contains(link.Destination))
{
subgraph.Nodes.Add(link.Destination);
nodes.Remove(link.Destination);
}
if (!subgraph.Links.Contains(link))
subgraph.Links.Add(link);
}
i++;
}
subgraphs.Add(subgraph);
}
IGraph[] result = new IGraph[subgraphs.Count];
for (int i = 0; i < subgraphs.Count; i++)
result[i] = subgraphs[i] as IGraph;
return result;
}