Esempio n. 1
0
        private void GetHomelessLinks(List<Link> _homelessLinks, Link link)
        {
            bool exists = false;
            //check if current source is called anywhere (is it an orphan?)
            foreach (Link item in _entityTreeLinks)
            {

                //for a link source, look through all other links to see if it is called (as target)
                if (item.Target.Equals(link.Source))
                {
                    exists = true;
                }
            }
            //if link source node does NOT exist as tree-link target
            if (!exists && !link.Source.Equals(0))
            {
                _homelessLinks.Add(link);
            }
        }
Esempio n. 2
0
        private Link AddNonTreeLink(Node source, Node target)
        {
            //write processing output to same line
            Console.Write("Building Link from {0} to {1}            \r", source.name, target.name);

            Link link = new Link();
            link.Source = source.id;
            link.Target = target.id;
            link.Id = entityLinkCount;
            _entityLinks.Add(link);
            _entityNonTreeLinks.Add(link);
            entityLinkCount++;

            return link;
        }
Esempio n. 3
0
        private Link AddTreeLink(Node source, Node target)
        {
            //write processing output to same line
            Console.Write("Building Link from {0} to {1}            \r", source.name, target.name);

            //add a 2nd check that inverse link does not exist as tree
            var loopLink = (from m in _entityTreeLinks
                            where m.Target == source.id
                            && m.Source == target.id
                            select m);

            Link link = new Link();
            link.Source = source.id;
            link.Target = target.id;

            if (!loopLink.Any())
            {

                link.Id = entityLinkCount;
                _entityLinks.Add(link);
                _entityTreeLinks.Add(link);
                entityLinkCount++;
            }

            return link;
        }
Esempio n. 4
0
        private Link AddLink(Node source, Node target)
        {
            //this is to fix a multi-line console display bug
            var bucket = (from b in _entityBucketNodes
                          where b.name == source.name
                          select b);
            if (!bucket.Any())
            {
                //write processing output to same line
                Console.Write("Building Link from {0} to {1}            \r", source.name, target.name);
            }

            Link link = new Link();
            link.Source = source.id;
            link.Target = target.id;

            //Add system to bucket links
            if (source.id.Equals(0))
            {
                link.Id = entityLinkCount;
                _entityLinks.Add(link);
                _entityTreeLinks.Add(link);
                entityLinkCount++;
            }

            //add other entity links
            else
            {
                    //if target does not already exist
                    var targetExists = (from n in _entityTreeLinks
                                        where n.Target.Equals(link.Target)
                                        select n);

                    //Add to list as tree
                    if (!targetExists.Any())
                    {
                        link.Id = entityLinkCount;
                        _entityLinks.Add(link);
                        _entityTreeLinks.Add(link);
                        entityLinkCount++;
                    }

                //If not tree link, add non-tree link
                else
                {
                    var linkExists = (from n in _entityLinks
                                      where n.Source.Equals(link.Source)
                                      && n.Target.Equals(link.Target)
                                      select n);
                    if (!linkExists.Any())
                    {
                        link.Id = entityLinkCount; ;
                        _entityLinks.Add(link);
                        _entityNonTreeLinks.Add(link);
                        entityLinkCount++;
                    }
                }
            }
            return link;
        }