|
|
|
@ -57,6 +57,7 @@ namespace CriticalPathAnalyzer.Server.Tool {
|
|
|
|
|
var clusterNodes = new List<ClusterNode>();
|
|
|
|
|
var clusterToNodeMapping = new Dictionary<Cluster, int>(); // Cluster / index of node
|
|
|
|
|
var queue = new Queue<ClusterNode>();
|
|
|
|
|
var loopingNodes = new HashSet<int>();
|
|
|
|
|
|
|
|
|
|
// An input peg, only has a single cluster.
|
|
|
|
|
// An output peg however can be connected to multiple clusters.
|
|
|
|
@ -125,6 +126,8 @@ namespace CriticalPathAnalyzer.Server.Tool {
|
|
|
|
|
// only add the link, don't propagate
|
|
|
|
|
if (!nextNode.PrevNodeIndexes.Add(node.Index)) {
|
|
|
|
|
logger.Warn("Loop detected");
|
|
|
|
|
loopingNodes.Add(node.Index);
|
|
|
|
|
loopingNodes.Add(nextNode.Index);
|
|
|
|
|
// already been here - there is a cycle
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
@ -161,13 +164,22 @@ namespace CriticalPathAnalyzer.Server.Tool {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Attempt to get the critical path length
|
|
|
|
|
// If the ending cluster has not been found, return -1
|
|
|
|
|
Cluster endingCluster = endingClusters.First();
|
|
|
|
|
int criticalPathLength = -1;
|
|
|
|
|
if (clusterToNodeMapping.TryGetValue(endingCluster, out int nodeIndex)) {
|
|
|
|
|
criticalPathLength = clusterNodes[nodeIndex].Time;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Collect information about each cluster:
|
|
|
|
|
response = new AnalyzePathResponse() {
|
|
|
|
|
RequestGuid = requestGuid,
|
|
|
|
|
Clusters = clusterNodes.SelectMany(node =>
|
|
|
|
|
node.Clusters.Select(cluster => CollectClusterInformation(cluster, node.Time))).ToList(),
|
|
|
|
|
CriticalPathLength = clusterNodes[clusterToNodeMapping[endingClusters.First()]].Time,
|
|
|
|
|
|
|
|
|
|
CriticalPathLength = criticalPathLength,
|
|
|
|
|
LoopingClusters = loopingNodes.SelectMany(loopingNodeIndex => clusterNodes[loopingNodeIndex].Clusters
|
|
|
|
|
.Select(cluster => CollectClusterInformation(cluster, 0))).ToList(),
|
|
|
|
|
// PerimeterComponents = perimeterComponents.ToList(),
|
|
|
|
|
// NextClusters = collectedNextClusters.Select(CollectClusterInformation).ToList(),
|
|
|
|
|
};
|
|
|
|
|