public ProjectPlus(int nodes) { size = nodes; time = new int[size][]; act = new AcitivityPlus[size]; degrees = new int[size]; for (int i = 0; i < size; i++) { time[i] = new int[size]; for (int j = 0; j < size; j++) { time[i][j] = -1; } act[i] = new AcitivityPlus(i); } }
private void feedBack(int ID) { Queue <int> q = new Queue <int>(); Stack <AcitivityPlus> s = new Stack <AcitivityPlus>(); bool[] visit = new bool[size]; q.Enqueue(ID); while (q.Count > 0) { int end = q.Dequeue(); bool onCrucialPath = false; for (int i = 0; i < size; i++) { if (time[i][end] >= 0) { if (act[i].late >= act[end].late - time[i][end]) { act[i].late = act[end].late - time[i][end]; if (act[i].late == act[i].early) { act[end].Add(act[i]); onCrucialPath = true; } } if (!visit[i]) { q.Enqueue(i); visit[i] = true; } } } if (onCrucialPath) { s.Push(act[end]); } } while (s.Count > 0) { AcitivityPlus newAct = s.Pop(); foreach (AcitivityPlus elem in newAct.GetParent()) { Console.WriteLine((elem.idx + 1) + "->" + (newAct.idx + 1)); } } }
public void Add(AcitivityPlus newAct) { parent.Add(newAct); }