Exemple #1
0
        private void reBuildTree(int rootID)
        {
            int clusterCount = PublicParameters.networkCells.Count();

            startFromCluster(CellGroup.getClusterWithID(rootID), true);
            for (int i = 0; (BFSvisited.Count == 0) || (i < clusterCount - 1); i++)
            {
                if (BFSvisited.Count() > 0)
                {
                    CellGroup         parent      = BFSvisited.Dequeue();
                    Queue <CellGroup> childrenQue = new Queue <CellGroup>();// parent.childrenClusters;
                    foreach (CellGroup child in parent.childrenClusters)
                    {
                        childrenQue.Enqueue(child);
                    }
                    int childrenCount = childrenQue.Count();
                    for (int q = 0; q < childrenCount; q++)
                    {
                        startFromCluster(childrenQue.Dequeue(), false);
                    }
                }
                else
                {
                    break;
                }
            }
        }
Exemple #2
0
        public void displayTree()
        {
            CellGroup root = CellGroup.getClusterWithID(rootClusterID);

            root.clusterLevel = 1;
            setLevel(root);
            saveLevels();
            //printLevels();
        }
Exemple #3
0
        private static void changeRootChildren()
        {
            CellGroup root = CellGroup.getClusterWithID(rootClusterID);

            foreach (CellGroup linked in root.clusterLinks.hasLinkwith)
            {
                if (linked.parentCluster.getID() != rootClusterID)
                {
                    double offset   = PublicParameters.cellRadius + PublicParameters.cellRadius / 2;
                    double distance = Operations.DistanceBetweenTwoPoints(linked.clusterActualCenter, root.clusterActualCenter);
                    // if (distance <= offset)
                    //{
                    CellGroup oldParent = CellGroup.getClusterWithID(linked.parentCluster.getID());
                    CellGroup child     = CellGroup.getClusterWithID(linked.getID());
                    oldParent.childrenClusters.Remove(linked);
                    child.parentCluster = root;
                    root.childrenClusters.Add(linked);
                    //}
                }
            }
        }
Exemple #4
0
        public static void changeTree(int nearClusterID)
        {
            if (nearClusterID != rootClusterID)
            {
                // PublicParamerters.currentNetworkTree.clusterTree.Clear();
                // The near cluster will be come the new root
                CellGroup oldRoot = CellGroup.getClusterWithID(rootClusterID);
                CellGroup newRoot = CellGroup.getClusterWithID(nearClusterID);
                // oldRoot.clusterHeader.headerSensor.ClusterHeader.SinkAgent = null;
                //Edit the old root cluster's children & parent
                oldRoot.parentCluster = newRoot;
                oldRoot.childrenClusters.Remove(newRoot);
                //Edit the new root cluster's children & parent
                newRoot.parentCluster = null;
                newRoot.childrenClusters.Add(oldRoot);
                rootCluster            = newRoot;
                rootClusterID          = newRoot.getID();
                MobileModel.rootTreeID = rootClusterID;
                changeRootChildren();
                //Here we need to send to all the new headers the new parametrs in it
                // oldRoot.clusterHeader.headerSensor.CellHeader.hasSinkPosition = false;
                // oldRoot.clusterHeader.headerSensor.CellHeader.isRootHeader = false;
                // oldRoot.clusterHeader.headerSensor.CellHeader.ClearBuffer();

                oldRoot.CellTable.CellHeader.TuftNodeTable.CellHeaderTable.hasSinkPosition = false;
                oldRoot.CellTable.CellHeader.TuftNodeTable.CellHeaderTable.isRootHeader    = false;
                oldRoot.CellTable.CellHeader.ClearCellHeaderBuffer();

                newRoot.CellTable.CellHeader.TuftNodeTable.CellHeaderTable.hasSinkPosition = false;
                newRoot.CellTable.CellHeader.TuftNodeTable.CellHeaderTable.SinkAgent       = null;
                newRoot.CellTable.CellHeader.TuftNodeTable.CellHeaderTable.isRootHeader    = true;
                // newRoot.CellTable.CellHeader.GenerateTreeChange(oldRoot.CellTable.CellHeader);

                CellFunctions.ChangeTreeLevels();
            }
        }