本文整理汇总了C#中AdjacencyGraph.OutEdges方法的典型用法代码示例。如果您正苦于以下问题:C# AdjacencyGraph.OutEdges方法的具体用法?C# AdjacencyGraph.OutEdges怎么用?C# AdjacencyGraph.OutEdges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdjacencyGraph
的用法示例。
在下文中一共展示了AdjacencyGraph.OutEdges方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindDecisionPattern
/// <summary>
/// Znajduje wszystkie paterny dec
/// </summary>
/// <param name="g"></param>
/// <returns></returns>
public AdjacencyGraph<Node, Edge<Node>> FindDecisionPattern(AdjacencyGraph<Node, Edge<Node>> g)
{
List<Node> decisionNodes = g.Vertices.Where(x => x.Type == NodeType.DecisionNode).ToList();
foreach (var decisionNode in decisionNodes)
{
var outEdges = g.OutEdges(decisionNode);
var left = outEdges.ElementAt(0).Target;
var right = outEdges.ElementAt(1).Target;
var upperEdge = g.Edges.Where(x => x.Target == decisionNode).ToList().FirstOrDefault();
if (g.OutEdges(left).Count() == 1 && g.OutEdges(right).Count() == 1 && (
g.OutEdges(left).ElementAt(0).Target == g.OutEdges(right).ElementAt(0).Target)
|| g.OutEdges(left).ElementAt(0).Target == right
|| g.OutEdges(right).ElementAt(0).Target == left
|| left.Type==NodeType.ActivityFinalNode
|| right.Type==NodeType.ActivityFinalNode)
{
string name = "dec(" + decisionNode.Name + ", " + left.Name + ", " + right.Name + ")";
var decisionPattern = new Node(name, NodeType.DecisionPattern);
g.AddVertex(decisionPattern);
var nextNode = g.OutEdges(right).ElementAt(0).Target;
if(nextNode == left || nextNode==right)
nextNode = g.OutEdges(left).ElementAt(0).Target;
g.AddEdge(new Edge<Node>(upperEdge.Source, decisionPattern));
g.AddEdge(new Edge<Node>(decisionPattern, nextNode));
g.RemoveVertex(decisionNode);
g.RemoveVertex(left);
g.RemoveVertex(right);
}
}
return g;
}
示例2: GetOrderedListOfDependencies
public static IEnumerable<string> GetOrderedListOfDependencies(AdjacencyGraph<string, Edge<string>> graph)
{
var vertices = graph.Vertices.ToList();
var orderedList = new List<string>();
while (vertices.Count > 0)
{
var vertexToRemove = new List<string>();
var edgesToRemove = new List<Edge<string>>();
foreach (var vertex in vertices)
{
var outEdges = graph.OutEdges(vertex).ToList();
if (outEdges.Count == 0)
{
orderedList.Add(vertex);
string vertex1 = vertex;
edgesToRemove.AddRange(graph.Edges.Where(edge => edge.Target == vertex1));
vertexToRemove.Add(vertex);
}
}
if (vertexToRemove.Count == 0)
throw new InvalidOperationException("Graph has circular dependencies");
edgesToRemove.ForEach(edge => graph.RemoveEdge(edge));
vertexToRemove.ForEach(vertex =>
{
graph.RemoveVertex(vertex);
vertices.Remove(vertex);
});
}
return orderedList;
}
示例3: FindSeqPattern
/// <summary>
/// Znajduje wszystkie paterny seq
/// </summary>
/// <param name="g"></param>
/// <returns></returns>
public AdjacencyGraph<Node, Edge<Node>> FindSeqPattern(AdjacencyGraph<Node, Edge<Node>> g)
{
var chuj = true;
while (chuj)
{
List<Edge<Node>> followingEdges = GetEdgesForSeq(g);
if (followingEdges.Count == 0)
{
chuj = false;
continue;
}
var followingEdge = followingEdges.FirstOrDefault();
//utworzenie nowego seq patternu
string name = "seq(" + followingEdge.Source.Name + "," + followingEdge.Target.Name + ")";
var seqPattern = new Node(name, NodeType.SeqPattern);
//znalezienie poprzedniego i nastepnego polaczenia polaczenia
var upperEdge = g.Edges.Where(x => x.Target == followingEdge.Source).ToList().FirstOrDefault();
var lowerEdge = g.OutEdges(followingEdge.Target).ElementAt(0);
//dodanie noda i polaczen
g.AddVertex(seqPattern);
g.AddEdge(new Edge<Node>(upperEdge.Source, seqPattern));
g.AddEdge(new Edge<Node>(seqPattern, lowerEdge.Target));
//usuniecie starych nodow
g.RemoveVertex(followingEdge.Source);
g.RemoveVertex(followingEdge.Target);
}
return g;
}
示例4: FindParPattern
/// <summary>
/// Znajduje wszystkie paterny par
/// </summary>
/// <param name="g"></param>
/// <returns></returns>
public AdjacencyGraph<Node, Edge<Node>> FindParPattern(AdjacencyGraph<Node, Edge<Node>> g)
{
List<Node> forkNodes = g.Vertices.Where(x => x.Type == NodeType.ForkNode).ToList();
foreach (var forkNode in forkNodes)
{
var forkEdges = g.Edges.Where(x => x.Source == forkNode).ToList();
var leftEdge = forkEdges[0];
var rightEdge = forkEdges[1];
var forkInEdge = g.Edges.Where(x => x.Target == forkNode).ToList().FirstOrDefault();
var leftOutNode = g.OutEdges(leftEdge.Target).ElementAt(0).Target;
var rightOutNode = g.OutEdges(rightEdge.Target).ElementAt(0).Target;
var startParNode = forkInEdge.Source;
var startParNodeInEdge = g.Edges.Where(x => x.Target == startParNode).ToList().FirstOrDefault();
if (leftOutNode == rightOutNode && leftOutNode.Type == NodeType.JoinNode)
{
string name = "par(" + forkInEdge.Source.Name + "," + leftEdge.Target.Name + "," +
rightEdge.Target.Name + ")";
var parPattern = new Node(name, NodeType.ParPattern);
//dodaje pattern
g.AddVertex(parPattern);
g.AddEdge(new Edge<Node>(startParNodeInEdge.Source, parPattern));
g.AddEdge(new Edge<Node>(parPattern, g.OutEdges(rightOutNode).ElementAt(0).Target));
//usuwa fork,join,a,b
g.RemoveVertex(leftEdge.Target);
g.RemoveVertex(rightEdge.Target);
g.RemoveVertex(forkNode);
g.RemoveVertex(rightOutNode);
g.RemoveVertex(startParNode);
}
}
return g;
}
示例5: FindAncestorSet
private HashSet<Int32> FindAncestorSet(AdjacencyGraph<Int32,Edge<Int32>> graph, Int32 node)
{
HashSet<Int32> result = new HashSet<Int32>();
foreach (Edge<Int32> outEdge in graph.OutEdges(node))
{
result.Add(outEdge.Target);
foreach (Int32 i in FindAncestorSet(graph, outEdge.Target))
result.Add(i);
}
return result;
}