private EnvironmentDeployment ReverseEnvironmentDeployment(EnvironmentDeployment environmentDeployment)
        {
            foreach (var productDeployment in environmentDeployment.ProductDeployments)
            {
                productDeployment.DeploymentSteps = ReverseProductDeployment(productDeployment.DeploymentSteps);
            }

            return(environmentDeployment);
        }
        public EnvironmentDeployment GetEnvironmentDeployment(ComponentDeploymentGraph componentDeploymentDependanciesAdjacencyGraph)
        {
            var weaklyConnectedComponents = (IDictionary <ComponentDeploymentVertex, int>) new Dictionary <ComponentDeploymentVertex, int>();

            componentDeploymentDependanciesAdjacencyGraph.WeaklyConnectedComponents(weaklyConnectedComponents);

            //Work out related components
            foreach (var connectedComponent in weaklyConnectedComponents)
            {
                connectedComponent.Key.ProductGroup = connectedComponent.Value;
            }

            var productGroupNames = weaklyConnectedComponents.Values
                                    .Distinct();

            var productDeploymentPlans = productGroupNames
                                         .Select(productGroupName => GetComponentGroups(componentDeploymentDependanciesAdjacencyGraph, productGroupName))
                                         .ToList();

            var environmentDeployment         = new EnvironmentDeployment(productDeploymentPlans);
            var reversedEnvironmentDeployment = ReverseEnvironmentDeployment(environmentDeployment);

            return(reversedEnvironmentDeployment);
        }