Ejemplo n.º 1
0
        private void ChangeLinksExistenceState(Graph graph, GraphPath secundaryPath, Graph ring)
        {
            for (int i = 0; i < secundaryPath.Path.Count - 1; i++)
            {
                GraphLink link = ring.Links.FirstOrDefault(r => r.From == secundaryPath.Path[i] && r.To == secundaryPath.Path[i + 1]);

                if (link != null)
                {
                    ring.RemoveLink(secundaryPath.Path[i], secundaryPath.Path[i + 1]);
                    ring.RemoveLink(secundaryPath.Path[i + 1], secundaryPath.Path[i]);
                }
                else
                {
                    link = graph.Links.FirstOrDefault(r => r.From == secundaryPath.Path[i] && r.To == secundaryPath.Path[i + 1]);

                    GraphLink linkCopy  = link.CopyObject <GraphLink>();
                    GraphLink linkCopy2 = link.CopyObject <GraphLink>();
                    linkCopy2.From = link.To;
                    linkCopy2.To   = link.From;
                    //set slots and granularity
                    ring.Links.Add(linkCopy2);
                    ring.Links.Add(linkCopy);
                }
            }
        }
Ejemplo n.º 2
0
        private Graph CreateRingSubGraph(Graph graph, GraphPath mainPath)
        {
            Graph ring = graph.CopyObject <Graph>();

            ring.Links = new List <GraphLink>();

            for (int i = 0; i < mainPath.Path.Count - 1; i++)
            {
                GraphLink link     = graph.Links.FirstOrDefault(r => r.From == mainPath.Path[i] && r.To == mainPath.Path[i + 1]);
                GraphLink linkCopy = link.CopyObject <GraphLink>();
                //set slots and granularity
                ring.Links.Add(linkCopy);
            }
            BuildDirectionLinks(ring);
            return(ring);
        }