Example #1
0
 private void Topology(List <int> snppids, List <int> capacities, List <string> areaNames, List <List <int> > reachableSNPPs)
 {
     for (int i = 0; i < snppids.Count; i++)
     {
         var res = abstractVertices.Find(x => x.ID == snppids[i]);
         if (res != null)
         {
             abstractVertices.Find(x => x.ID == snppids[i]).Capacity       = capacities[i];
             abstractVertices.Find(x => x.ID == snppids[i]).AreaName       = areaNames[i];
             abstractVertices.Find(x => x.ID == snppids[i]).ReachableNodes = reachableSNPPs[i];
         }
         else
         {
             AbstractVertex tmpAbstractVertex = new AbstractVertex(snppids[i], capacities[i], 5, areaNames[i], reachableSNPPs[i]);
             Console.WriteLine("id: " + snppids[i]);
             foreach (int id in reachableSNPPs[i])
             {
                 Console.WriteLine(id);
             }
             abstractVertices.Add(tmpAbstractVertex);
         }
     }
     graph = createGraph(abstractVertices);
     if (!_myAreaName.Contains("Dom"))
     {
         Dijkstra dijkstra  = new Dijkstra(_myAreaName);
         var      pathsInfo = dijkstra.runAlgorithmForAll(graph);
         foreach (PathInfo pathInfo in pathsInfo)
         {
             Thread.Sleep(100);
             LocalTopology(pathInfo.beginEnd, pathInfo.Weight, pathInfo.Capacity, pathInfo.AreaName, _domainIpAddress);
         }
     }
 }
Example #2
0
        private void InitialiseVariables(string configurationFilePath)
        {
            _configurationFilePath = configurationFilePath;

            RC_XmlSchame tmp  = new RC_XmlSchame();
            Topology     temp = new Topology();

            tmp = RC_LoadingXmlFile.Deserialization(_configurationFilePath);
            _localPcIpAddress = tmp.XML_myIPAddress;
            _myAreaName       = tmp.XMP_myAreaName;
            _domainIpAddress  = tmp.XMP_DomainIpAddress;
            if (_myAreaName.Equals("Dom_1"))
            {
                if (tmp.Translate1 != null)
                {
                    foreach (var v in tmp.Translate1)
                    {
                        SN_1ToDomain.Add(v.ID_SN_1, v.ID_Domain);
                    }
                }
                if (tmp.Translate2 != null)
                {
                    foreach (var v in tmp.Translate2)
                    {
                        SN_2ToDomain.Add(v.ID_SN_2, v.ID_Domain);
                    }
                }
            }
            if (tmp.iptoidDictionary != null)
            {
                foreach (var v in tmp.iptoidDictionary)
                {
                    IPTOIDDictionary.Add(v.IP, v.ID);
                }
            }
            if (tmp.interdomainDictionary != null)
            {
                foreach (var v in tmp.interdomainDictionary)
                {
                    interdomainLinksDictionary.Add(v.id1, v.id2);
                }
            }
            foreach (var v in tmp.LocalTopology)
            {
                AbstractVertex tmpAbstractVertex = new AbstractVertex(v.ID, v.capacity, v.weight, v.areaName, v.reachableNodes);
                abstractVertices.Add(tmpAbstractVertex);
            }
        }
Example #3
0
        public Graph createGraph(List <AbstractVertex> abstractVertices)
        {
            Graph graph = new Graph();

            List <Vertex> vertices = new List <Vertex>();

            foreach (AbstractVertex v in abstractVertices)
            {
                Vertex tmpVertex = new Vertex(v.ID, v.Capacity, v.Weight, v.AreaName);
                vertices.Add(tmpVertex);
            }
            foreach (Vertex currentVertex in vertices)
            {
                AbstractVertex tmpAbstractVertex = abstractVertices.Find(x => x.ID == currentVertex.Id);
                if (tmpAbstractVertex != null)
                {
                    foreach (int id in tmpAbstractVertex.ReachableNodes)
                    {
                        Vertex end = vertices.Find(x => x.Id == id);
                        if (end != null)
                        {
                            Edge edge = new Edge(currentVertex, end, tmpAbstractVertex.Capacity, tmpAbstractVertex.Weight);
                            if (!edge.Begin.AreaName.Equals(_myAreaName))
                            {
                                if (edge.Begin.AreaName.Equals(edge.End.AreaName))
                                {
                                    edge.SubDomain = true;
                                }
                            }
                            currentVertex.EdgesOut.Add(edge);
                            graph.Edges.Add(edge);
                        }
                    }
                }
                graph.Vertices.Add(currentVertex);
            }

            return(graph);
        }