コード例 #1
0
        private void populateNextHopeCandidates()
        {
            RingNodeCandidate         fromPoint = StartingPoint;
            Queue <RingNodeCandidate> queue     = new Queue <RingNodeCandidate>();

            queue.Enqueue(fromPoint);

            while (queue.Count > 0)
            {
                fromPoint = queue.Dequeue();
                if (fromPoint.NextHopCandidate.Count == 0)
                {
                    foreach (Sensor neighbor in fromPoint.node.NeighborsTable)
                    {
                        foreach (RingNodeCandidate candidate in RingNodeCandidates)
                        {
                            if (neighbor.ID == candidate.node.ID)
                            {
                                fromPoint.NextHopCandidate.Add(candidate);
                                queue.Enqueue(candidate);
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        private void findRingCandidates()
        {
            List <Sensor> networkNodes = PublicParamerters.MainWindow.myNetWork;

            foreach (Sensor cand in networkNodes)
            {
                double distance   = Operations.DistanceBetweenTwoPoints(cand.CenterLocation, NetworkCenter);
                double difference = (distance - InitialRadius);
                if (difference <= ThreshHold && difference >= 0)
                {
                    //   cand.Ellipse_indicator.Visibility = Visibility.Visible;
                    RingNodeCandidate candidate = new RingNodeCandidate(cand, difference);
                    RingNodeCandidates.Add(candidate);
                }
            }
        }
コード例 #3
0
        private void getStartingPoint()
        {
            double lowest = ThreshHold;

            foreach (RingNodeCandidate cand in RingNodeCandidates)
            {
                if (cand.difference < ThreshHold)
                {
                    lowest        = cand.difference;
                    StartingPoint = cand;
                }
            }
            try
            {
            }
            catch
            {
                StartingPoint = null;
            }
        }
コード例 #4
0
        private void startBuildingFromPoint(RingNodeCandidate fromPoint)
        {
            counter++;
            double            lowest    = ThreshHold + 10;
            RingNodeCandidate nextCandi = null;

            if (fromPoint.node.ID == 57)
            {
                //  Console.WriteLine();
            }
            foreach (RingNodeCandidate candi in fromPoint.NextHopCandidate)
            {
                if (counter > 5 && candi == StartingPoint)
                {
                    nextCandi                 = candi;
                    fromPoint.nextHop         = StartingPoint.node;
                    fromPoint.alreadyRingNode = true;
                    RNodes.Add(fromPoint);
                    return;
                }
                if (candi.difference < lowest && !candi.alreadyRingNode)
                {
                    lowest    = candi.difference;
                    nextCandi = candi;
                }
            }

            if (nextCandi == null)
            {
                MessageBox.Show("Null here");
                return;
            }

            fromPoint.nextHop         = nextCandi.node;
            fromPoint.alreadyRingNode = true;
            RNodes.Add(fromPoint);
            PreviousRingNodes.Add(nextCandi.node);
            startBuildingFromPoint(nextCandi);
        }