private void InitializeLandscapeComponent()
        {
            //Create BasicPlain
            BasicPlain.Add(new LandscapeRange()
            {
                Name          = "Flat",
                Color         = Color.AliceBlue,
                Size          = 0.2,
                MixedNextArea = 0.05
            });
            BasicPlain.Add(new LandscapeRange()
            {
                Name          = "Plain",
                Color         = Color.YellowGreen,
                Size          = 0.5,
                MixedNextArea = 0.05
            });
            BasicPlain.Add(new LandscapeRange()
            {
                Name  = "Hill",
                Color = Color.Tomato,
                Size  = 0.3
            });

            //Create BasicMidLand
            BasicMidland.Add(new LandscapeRange()
            {
                Name  = "Midland",
                Color = Color.Wheat,
                Size  = 1
            });
            //Create BasicMontain
            BasicMontain.Add(new LandscapeRange()
            {
                Name  = "Montain",
                Color = Color.Brown,
                Size  = 1
            });
            //Create BasicOcean
            BasicOcean.Add(new LandscapeRange()
            {
                Name  = "Ocean",
                Color = Color.Navy,
                Size  = 1
            });

            //Create Ground
            Ground.Add(new LandscapeRange()
            {
                Name          = "BasicPlain",
                Color         = Color.Green,
                Size          = 0.4,
                MixedNextArea = 0.05
            });
            Ground.Add(new LandscapeRange()
            {
                Name          = "BasicMidLand",
                Color         = Color.YellowGreen,
                Size          = 0.3,
                MixedNextArea = 0.05
            });
            Ground.Add(new LandscapeRange()
            {
                Name  = "BasicMontain",
                Color = Color.Brown,
                Size  = 0.3
            });

            //Create Ocean
            Ocean.Add(new LandscapeRange()
            {
                Name  = "BasicOcean",
                Color = Color.Navy,
                Size  = 1
            });

            //Create World
            World.Add(new LandscapeRange()
            {
                Name          = "Ocean",
                Color         = Color.Navy,
                Size          = 0.1,
                MixedNextArea = 0.02
            });

            World.Add(new LandscapeRange()
            {
                Name  = "Ground",
                Color = Color.Gold,
                Size  = 0.9
            });
        }
        private void Analyze()
        {
            // Build the ocean
            //	- an ocean (set) of islands (set)
            //	- also a hash for TopicAnalysis (topic->{island set,refcount}) for quick check if already present
            _referenceMap = _namespaceManager.GetReferenceMap(ExistencePolicy.ExistingOnly);

            foreach (string outerTopic in _referenceMap.Keys)
            {
                Ocean islands = new Ocean();
                QualifiedTopicRevisionCollection linkedTopics = _referenceMap[outerTopic];

                QualifiedTopicRevision outerRevision = new QualifiedTopicRevision(outerTopic, _namespaceManager.Namespace);
                TopicAnalysis outerTopicAnalysis = null;
                if (!_topicToTopicAnalysis.ContainsKey(outerRevision))
                {
                    outerTopicAnalysis = new TopicAnalysis();
                    _topicToTopicAnalysis[outerRevision] = outerTopicAnalysis;
                }
                else
                {
                    outerTopicAnalysis = _topicToTopicAnalysis[outerRevision];
                }

                if (outerTopicAnalysis.Island != null)
                {
                    islands.Add(outerTopicAnalysis.Island);
                }

                //	- foreach outer topic
                //		islands = new set
                //		foreach linked topic
                //			increment refcount for linked topic
                //			if (linkedtopic is on an island)
                //				islands add that island
                Island inNamespaceLinks = new Island();
                foreach (QualifiedTopicRevision linkedTopic in linkedTopics)
                {
                    // Only analyze in this namespace
                    if (linkedTopic.Namespace != _namespaceManager.Namespace)
                    {
                        // Response.Write("Skiping linked topic (" + linkedTopic.Name + ") because namespace doesn't match<br>");
                        continue;
                    }
                    // Only do each topic once; have we seen this one?
                    if (inNamespaceLinks.Contains(linkedTopic))
                    {
                        // Response.Write("Skiping linked topic (" + linkedTopic.Name + ") because seen before<br>");
                        continue;
                    }
                    // Skip self-references
                    if (linkedTopic.Equals(outerTopic))
                    {
                        continue;
                    }

                    inNamespaceLinks.Add(linkedTopic);
                    TopicAnalysis linkedTopicAnalysis = null;
                    if (!_topicToTopicAnalysis.ContainsKey(linkedTopic))
                    {
                        linkedTopicAnalysis = new TopicAnalysis();
                        _topicToTopicAnalysis[linkedTopic] = linkedTopicAnalysis;
                    }
                    else
                    {
                        linkedTopicAnalysis = _topicToTopicAnalysis[linkedTopic];
                    }
                    linkedTopicAnalysis.RefCount++;
                    if (linkedTopicAnalysis.Island != null)
                    {
                        islands.Add(linkedTopicAnalysis.Island);
                    }
                }

                //		if (islands is empty)
                //			create new island
                //			add outer topic and all linked topics
                //		else if (islands size == 1)
                //			add all links and the outer topic to that islands
                //		else
                //			// need to merge islands
                //			newset = merged set of all islands
                //			TopicAnalysiss and replace and of the old islands with the new island

                Island newIsland;
                if (islands.Count == 1)
                {
                    newIsland = islands.First;	// if there's only one, we can just use that one
                }
                else
                {
                    newIsland = new Island();
                    _ocean.Add(newIsland);
                }
                // Add the island and the linkedTopics
                newIsland.Add(new QualifiedTopicRevision(outerTopic, _namespaceManager.Namespace));
                outerTopicAnalysis.Island = newIsland;
                foreach (QualifiedTopicRevision linkedTopic in inNamespaceLinks)
                {
                    newIsland.Add(linkedTopic);
                    _topicToTopicAnalysis[linkedTopic].Island = newIsland;
                    // Response.Write("Placing " + linkedTopic.Name + "<br>");
                }
                // Now merge if there was originally more than one
                if (islands.Count > 1)
                {
                    foreach (Island eachIsland in islands)
                    {
                        foreach (QualifiedTopicRevision revision in eachIsland)
                        {
                            newIsland.Add(revision);
                        }
                        _ocean.Remove(eachIsland);
                        // Now update all the pointers from the TopicAnalysiss
                        foreach (QualifiedTopicRevision eachTopic in eachIsland)
                        {
                            _topicToTopicAnalysis[eachTopic].Island = newIsland;
                        }
                    }
                }
            }
        }