Esempio n. 1
0
        public static void AddLink(int srcId, int destId, double bw, double lat)
        {
            if (Graph == null)
            {
                Graph = new TopologicalGraph();
            }

            if (Map == null)
            {
                Map = new Dictionary <int, int>();
            }

            if (!Map.ContainsKey(srcId))
            {
                Graph.AddNode(new TopologicalNode(NextIdx));
                Map.Add(srcId, NextIdx);
                NextIdx++;
            }

            if (!Map.ContainsKey(destId))
            {
                Graph.AddNode(new TopologicalNode(NextIdx));
                Map.Add(destId, NextIdx);
                NextIdx++;
            }

            Graph.AddLink(new TopologicalLink(Map[srcId], Map[destId], (float)lat, (float)bw));
            GenerateMatrices();
        }
Esempio n. 2
0
        private static double[][] CreateBwMatrix(TopologicalGraph graph, bool directed)
        {
            int nodes = Graph.NumberOfNodes;

            double[][] mtx = new double[nodes][];

            for (var i = 0; i < nodes; i++)
            {
                mtx[i] = new double[nodes];
            }

            var enumerator = graph.GetLinkEnumerator();

            do
            {
                TopologicalLink edge = enumerator.Current;

                if (edge != null)
                {
                    mtx[edge.SrcNodeId][edge.DestNodeId] = edge.LinkBw;

                    if (!directed)
                    {
                        mtx[edge.DestNodeId][edge.SrcNodeId] = edge.LinkBw;
                    }
                }
            } while (enumerator.MoveNext());

            return(mtx);
        }
Esempio n. 3
0
        public static void BuildNetworkTopology(string filename)
        {
            Log.WriteConcatLine("Topology file: ", filename);

            GraphReaderBrite reader = new GraphReaderBrite();

            try
            {
                Graph = reader.ReadGraphFile(filename);
                Map   = new Dictionary <int, int>();
                GenerateMatrices();
            }
            catch (IOException e)
            {
                Log.WriteLine("Problem in process BRITE file. Network simulation is disabled.");
                Log.WriteLine($"Error: {e.Message}");
            }
        }