Example #1
0
        public void CreateEdges(int num_edges)
        {
            Console.WriteLine("================================================================");

            Console.WriteLine("Creating " + num_edges + " edges");
            const int RANDOM_SEED = 55555;

            DateTime dt   = DateTime.Now;
            Node     from = new Node();
            Node     to   = new Node();

            for (int z = 0; z < (5 * num_edges); z++)
            {
                // Get two random nodes from node_list
                Random rand = new Random(RANDOM_SEED + z);
                int    r    = rand.Next(node_list.Count);
                //Console.WriteLine("First r = " + r);
                from = searchNode(r);
                // get one more random number
                r = rand.Next(node_list.Count);
                //Console.WriteLine("second r = " + r);
                to = searchNode(r);

                // dont allow self loops as of now
                if (from.node_id == to.node_id)
                {
                    r  = rand.Next(node_list.Count);
                    to = searchNode(r);
                }
                // avoid creating duplpicate edges between nodes
                if (isEdge(from.node_id, to.node_id))
                {
                    Console.WriteLine("Avoiding duplicate edges");
                    r  = rand.Next(node_list.Count);
                    to = searchNode(r);
                }

                //now we have 2 random nodes. see if we can hook up these two
                Waxman w       = new Waxman();
                double value   = 0.0;
                double compare = 0.0;
                compare = rand.NextDouble();
                value   = w.ProbFunc(from, to);
                //Console.WriteLine("Compare = " + compare + " value = " + value);

                Random rndm = new Random();
                if (value < compare)
                {
                    int rndm_num = rand.Next(1, 100);

                    Console.WriteLine("Connecting edge from " + to.node_id + " to " + from.node_id + " with cost = " + rndm_num);
                    from.addAdjNode(to, rndm_num);
                    to.addAdjNode(from, rndm_num);
                }
            }
        }
Example #2
0
        public Node(int id, int num_nodes)
        {
            Waxman w = new Waxman();

            this.Xpos = w.GetRandomX(id);
            this.Ypos = w.GetRandomY(id);

            edge_list = new List <Edge>(num_nodes);
            node_id   = id;
            Console.WriteLine("Creating Node " + this.node_id + " at (" + this.Xpos + "," + this.Ypos + ")");
        }
Example #3
0
        public void CreateEdges(int num_edges)
        {
            Console.WriteLine("================================================================");

            Console.WriteLine("Creating " + num_edges + " edges");
            const int RANDOM_SEED = 55555;

            DateTime dt = DateTime.Now;
            Node from = new Node();
            Node to = new Node();
             for (int z = 0; z < (5 * num_edges); z++)
            {
                // Get two random nodes from node_list
                Random rand = new Random(RANDOM_SEED + z);
                int r = rand.Next(node_list.Count);
                //Console.WriteLine("First r = " + r);
                from = searchNode(r);
                // get one more random number
                r = rand.Next(node_list.Count);
                //Console.WriteLine("second r = " + r);
                to = searchNode(r);

                // dont allow self loops as of now
                if (from.node_id == to.node_id)
                {
                    r = rand.Next(node_list.Count);
                    to = searchNode(r);
                }
                // avoid creating duplpicate edges between nodes
                if(isEdge(from.node_id, to.node_id))
                {
                    Console.WriteLine("Avoiding duplicate edges");
                    r = rand.Next(node_list.Count);
                    to = searchNode(r);
                }

                //now we have 2 random nodes. see if we can hook up these two
                Waxman w = new Waxman();
                double value = 0.0;
                double compare = 0.0;
                compare = rand.NextDouble();
                value = w.ProbFunc(from, to);
                //Console.WriteLine("Compare = " + compare + " value = " + value);

                Random rndm = new Random();
                if (value < compare)
                {

                    int rndm_num = rand.Next(1, 100);

                    Console.WriteLine("Connecting edge from " + to.node_id + " to " + from.node_id + " with cost = " + rndm_num);
                    from.addAdjNode(to, rndm_num);
                    to.addAdjNode(from, rndm_num);
                }

            }
        }
Example #4
0
        public Node(int id, int num_nodes)
        {
            Waxman w = new Waxman();

            this.Xpos = w.GetRandomX(id);
            this.Ypos = w.GetRandomY(id);

            edge_list = new List<Edge>(num_nodes);
            node_id = id;
            Console.WriteLine("Creating Node " + this.node_id + " at (" + this.Xpos + "," + this.Ypos + ")");
        }