public int Analyze() { this.AsIGraphNode().Clear(); if (this.Equals(End)) { criticalPathLength = 0; return(criticalPathLength); } if (criticalPaths.Any()) { return(criticalPathLength); } criticalPathLength = -1; foreach (IGraphEdge edge in registeredEdges) { if (edge.GetStartNode().Equals(this)) { IGraphNode node = edge.GetEndNode(); int candidate = node.Analyze(); node.MarkAsNormal(); if (candidate < 0) { node.MarkAsLoose(); loosePaths.Add(edge); } else if (candidate > criticalPathLength) { criticalPathLength = candidate; criticalPaths.Clear(); criticalPaths.Add(edge); } else if (candidate == criticalPathLength) { criticalPaths.Add(edge); } } } if (criticalPathLength < 0) { return(criticalPathLength); } if (this.Equals(Start) && this.criticalPathLength >= 0) { this.AsIGraphNode().MarkAsCritical(); } return(criticalPathLength + (int)duration); }