public void AddBiconnectedComponent(BiconnectedComponent component)
        {
            if (biconnectedComponents == null)
            {
                biconnectedComponents = new HashSet <BiconnectedComponent>();
            }
            int countBefore = biconnectedComponents.Count;

            biconnectedComponents.Add(component);
            int countAfter = biconnectedComponents.Count;

            if (countAfter != countBefore)
            {
                if (countBefore == 1)
                {
                    // It has just become a cut vertex. Update both components accordingly:
                    foreach (BiconnectedComponent existingComponent in biconnectedComponents)
                    {
                        existingComponent.AddCutVertex(this);
                    }
                }
                else
                if (countBefore > 1)
                {
                    // It was already a cut vertex. So just add as a cut vertex to the new component:
                    component.AddCutVertex(this);
                }

                // If in use, update the string listing of the components:
                if (biconnectedComponentsListing != null)
                {
                    BiconnectedComponentsListing = CalculateBiconnectedComponentsListing();
                }
            }
        }
        public void CalculateSubtreeMetricsForOpponent(MetricsEvaluator evaluator, BiconnectedComponent entryComponent)
        {
            EntryComponentForOpponent = entryComponent;
            BiconnectedComponent bestComponent = null;
            double valueOfBestComponent        = double.NegativeInfinity;
            int    branchCount = 0;

            // TODO: Order the components from most promising to least promising, in case there is a cycle:
            foreach (BiconnectedComponent component in biconnectedComponents)
            {
                if (component != entryComponent) // TODO: && component.OccupationStatus != OccupationStatus.You)
                {
                    if (component.IsSubTreeVisitedForOpponent)
                    {
                        System.Diagnostics.Debug.WriteLine("Component {0} not being visited, as it has been visited previously for Opponent");
                    }
                    else
                    {
                        component.CalculateSubtreeMetricsForOpponent(evaluator, this);
                        Metrics componentSubtreeMetrics = component.SubtreeMetricsForOpponent;

                        double valueOfComponent = evaluator.Evaluate(componentSubtreeMetrics);
                        if (valueOfComponent >= valueOfBestComponent)
                        {
                            valueOfBestComponent = valueOfComponent;
                            bestComponent        = component;
                        }
                        branchCount += componentSubtreeMetrics.NumberOfComponentBranchesInTree;
                    }
                }
            }

            // If this is a leaf cut vertex, then its branchCount is 1:
            if (branchCount == 0)
            {
                branchCount = 1;
            }

            ExitComponentForOpponent = bestComponent;
            Metrics opponentsMetricsForCutVertexOnly = CalculateOpponentsMetricsForCellStateOnly();

            if (bestComponent == null)
            {
                subtreeMetricsForOpponent = opponentsMetricsForCutVertexOnly;
            }
            else
            {
                subtreeMetricsForOpponent = opponentsMetricsForCutVertexOnly + bestComponent.SubtreeMetricsForOpponent;
            }

            subtreeMetricsForOpponent.NumberOfComponentBranchesInTree = branchCount;
            IsSubTreeVisitedForOpponent = true;
        }