private ReturnState FTraverse(BFGTNode x, BFGTNode y, LinkedList <BFGTNode> F, BFGTNode v, LinkedList <BFGTNode> B, List <BFGTNode> backupStack) { if (y == v || B.Contains(y)) { return(ReturnState.Cycle); } if (x.Level == y.Level) { y.Incoming.Add(x.Label); } if (x.Level > y.Level) { y.Level = x.Level; y.Incoming.Clear(); y.Incoming.Add(x.Label); if (!y.VisitedF) { return(FVisit(y, F, v, B, backupStack)); } } return(ReturnState.Normal); }
private ReturnState FVisit(BFGTNode x, List <BFGTNode> F, BFGTNode v, List <BFGTNode> B, List <BFGTNode> backupStack) { x.Visited = true; foreach (var outNode in x.Outgoing) { if (CycleBackup && !nodes[outNode].Visited) { backupStack.Add(new BFGTNode(nodes[outNode].Level, nodes[outNode].Index, nodes[outNode].Label, b, new List <int>(nodes[outNode].Incoming), new List <int>(nodes[outNode].Outgoing))); } if (FTraverse(x, nodes[outNode], F, v, B, backupStack) == ReturnState.Cycle) { x.Visited = false; return(ReturnState.Cycle); } } F.Insert(0, x); return(ReturnState.Normal); }
private ReturnState BTraverse(BFGTNode x, BFGTNode y, List <BFGTNode> B, ref int arcs, BFGTNode w) { if (x == w) { return(ReturnState.Cycle); } arcs++; if (arcs >= delta) { return(ReturnState.Delta); } if (!x.Visited) { return(BVisit(x, B, ref arcs, w)); } return(ReturnState.Normal); }
private ReturnState BVisit(BFGTNode y, List <BFGTNode> B, ref int arcs, BFGTNode w) { y.Visited = true; var retState = ReturnState.Normal; foreach (var inNode in y.Incoming) { retState = BTraverse(nodes[inNode], y, B, ref arcs, w); if (retState == ReturnState.Cycle) { y.Visited = false; return(retState); } if (retState == ReturnState.Delta) { y.Visited = false; break; } } B.Add(y); y.Visited = false; return(retState); }
private ReturnState FVisit(BFGTNode x, List<BFGTNode> F, BFGTNode v, List<BFGTNode> B, List<BFGTNode> backupStack) { x.Visited = true; foreach (var outNode in x.Outgoing) { if (CycleBackup && !nodes[outNode].Visited) { backupStack.Add(new BFGTNode(nodes[outNode].Level, nodes[outNode].Index, nodes[outNode].Label, b, new List<int>(nodes[outNode].Incoming), new List<int>(nodes[outNode].Outgoing))); } if (FTraverse(x, nodes[outNode], F, v, B, backupStack) == ReturnState.Cycle) { x.Visited = false; return ReturnState.Cycle; } } F.Insert(0, x); return ReturnState.Normal; }
private ReturnState FTraverse(BFGTNode x, BFGTNode y, List<BFGTNode> F, BFGTNode v, List<BFGTNode> B, List<BFGTNode> backupStack) { if (y == v || B.Contains(y)) return ReturnState.Cycle; if (x.Level == y.Level) y.Incoming.Add(x.Label); if (x.Level > y.Level) // Todo should x be w { y.Level = x.Level; y.Incoming.Clear(); y.Incoming.Add(x.Label); if (!y.Visited) return FVisit(y, F, v, B, backupStack); } return ReturnState.Normal; }
private ReturnState BVisit(BFGTNode y, List<BFGTNode> B, ref int arcs, BFGTNode w) { y.Visited = true; var retState = ReturnState.Normal; foreach (var inNode in y.Incoming) { retState = BTraverse(nodes[inNode], y, B, ref arcs, w); if (retState == ReturnState.Cycle) { y.Visited = false; return retState; } if (retState == ReturnState.Delta) { y.Visited = false; break; } } B.Add(y); y.Visited = false; return retState; }
private ReturnState BTraverse(BFGTNode x, BFGTNode y, List<BFGTNode> B, ref int arcs, BFGTNode w) { if (x == w) return ReturnState.Cycle; arcs++; if (arcs >= delta) { return ReturnState.Delta; } if (!x.Visited) return BVisit(x, B, ref arcs, w); return ReturnState.Normal; }