/// <summary>
        /// 得到局部聚类的EdgeList
        /// </summary>
        /// <param name="subGraph"></param>
        /// <returns></returns>
        private List <ITinEdge> GetLocalEdgeList(ASCDTSubGraph subGraph)
        {
            List <ITinEdge> localEdge = new List <ITinEdge>();

            double mean1StDev = Mean1StDev(subGraph);

            for (int i = 0; i < subGraph.GetNodeList().Count; i++)
            {
                ITinNode localNode       = subGraph.GetNodeList()[i];
                double   local2Mean      = Local2Mean(localNode, subGraph);
                double   localConstraint = local2Mean + mean1StDev;

                ITinEdgeArray incidentEdges = localNode.GetIncidentEdges();
                for (int j = 0; j < incidentEdges.Count; j++)
                {
                    ITinEdge currenEdge = incidentEdges.get_Element(j);
                    if (IsInEdges(currenEdge, subGraph.GetEdgeList()) && currenEdge.Length < localConstraint)
                    {
                        localEdge.Add(currenEdge);
                    }
                }
            }
            //去掉多加的neighbor边
            localEdge = CompleteEdges(localEdge);
            return(localEdge);
        }
        /// <summary>
        /// 获得全局聚类的EdgeList
        /// </summary>
        /// <returns></returns>
        private List <ITinEdge> GetGlobalEdgeList()
        {
            List <ITinEdge> globalEdge  = new List <ITinEdge>();
            ITinAdvanced    tinAdvanced = m_DT as ITinAdvanced;

            double globalMean  = GlobalMean(m_DT);
            double globalStDev = GlobalStDev(m_DT, globalMean);
            int    nodeCount   = tinAdvanced.NodeCount;

            for (int i = 1; i <= nodeCount; i++)
            {
                ITinNode tinNode          = tinAdvanced.GetNode(i);
                double   local1Mean       = Local1Mean(tinNode);
                double   globalConstraint = globalMean * (1 + globalStDev / local1Mean);

                ITinEdgeArray incdentEdges     = tinNode.GetIncidentEdges();
                int           incdentEdgeCount = incdentEdges.Count;

                for (int j = 0; j < incdentEdgeCount; j++)
                {
                    ITinEdge currentEdge = incdentEdges.get_Element(j);
                    if (currentEdge.Length < globalConstraint && currentEdge.IsInsideDataArea)
                    {
                        globalEdge.Add(currentEdge);
                    }
                }
            }

            //去掉多加的neighbor边
            globalEdge = CompleteEdges(globalEdge);
            return(globalEdge);
        }
        /// <summary>
        /// 整体边长标准差(全局)
        /// </summary>
        /// <param name="tin"></param>
        /// <param name="globalMean"></param>
        /// <returns></returns>
        private double GlobalStDev(ITin tin, double globalMean)
        {
            double       a           = 0;
            ITinAdvanced tinAdvanced = tin as ITinAdvanced;
            int          edgeCount   = tinAdvanced.EdgeCount;

            //            int edgeCount = tinAdvanced.DataEdgeCount;
            for (int i = 1; i <= edgeCount; i++)
            {
                if (tinAdvanced.GetEdge(i).IsInsideDataArea)
                {
                    ITinEdge tinEdge = tinAdvanced.GetEdge(i);
                    a = a + (globalMean - tinEdge.Length) * (globalMean - tinEdge.Length);
                }
            }
            return(System.Math.Sqrt(a / (double)tinAdvanced.DataEdgeCount));
        }
        /// <summary>
        /// 判断边edge是否在edgeList中
        /// </summary>
        /// <param name="edge"></param>
        /// <param name="edgeList"></param>
        /// <returns></returns>
        private bool IsInEdges(ITinEdge edge, List <ITinEdge> edgeList)
        {
            bool b = false;

            if (edgeList.Count == 0)
            {
                return(b);
            }
            for (int i = 0; i < edgeList.Count; i++)
            {
                if (edge.Index == edgeList[i].Index)
                {
                    b = true;
                    break;
                }
            }
            return(b);
        }
        /// <summary>
        /// 得到二阶邻接边
        /// </summary>
        /// <param name="currentNode"></param>
        /// <param name="subGraph"></param>
        /// <returns></returns>
        private List <ITinEdge> Get2IncidentEdges(ITinNode currentNode, ASCDTSubGraph subGraph)
        {
            List <ITinEdge> incidentEdges = new List <ITinEdge>();
            List <ITinEdge> subGraphEdge  = subGraph.GetEdgeList();
            List <ITinNode> subGraphNode  = subGraph.GetNodeList();

            //加入一阶邻接边
            ITinEdgeArray incEdges = currentNode.GetIncidentEdges();

            for (int j = 0; j < incEdges.Count; j++)
            {
                if (IsInEdges(incEdges.get_Element(j), subGraphEdge))
                {
                    incidentEdges.Add(incEdges.get_Element(j));
                }
            }
            //查找相邻点,加入二阶邻接边
            ITinNodeArray adjNodes = currentNode.GetAdjacentNodes();

            for (int j = 0; j < adjNodes.Count; j++)
            {
                if (!IsInNodes(adjNodes.get_Element(j), subGraphNode))
                {
                    continue;
                }
                ITinEdgeArray inc2Edges = adjNodes.get_Element(j).GetIncidentEdges();
                for (int k = 0; k < inc2Edges.Count; k++)
                {
                    ITinEdge edge = inc2Edges.get_Element(k);
                    if (IsInEdges(edge, incidentEdges))
                    {
                        continue;
                    }
                    if (IsInEdges(edge, subGraphEdge))
                    {
                        incidentEdges.Add(edge);
                    }
                }
            }

            return(incidentEdges);
        }
        private ASCDTSubGraph ExpandSubGraph(ITinNode currentNode, List <ITinEdge> globalEdge, ASCDTSubGraph newSubGraph)
        {
            m_nodeFlag[currentNode.Index - 1] = 1;
            newSubGraph.AddNode(currentNode);

            ITinEdgeArray incidentEdges = currentNode.GetIncidentEdges();

            for (int i = 0; i < incidentEdges.Count; i++)
            {
                ITinEdge currentEdge = incidentEdges.get_Element(i);
                if (IsInEdges(currentEdge, globalEdge))
                {
                    newSubGraph.AddEdge(currentEdge);
                    ITinNode nextNode = currentEdge.ToNode;
                    if (m_nodeFlag[nextNode.Index - 1] == 0)
                    {
                        ExpandSubGraph(nextNode, globalEdge, newSubGraph);
                    }
                }
            }
            return(newSubGraph);
        }
        /// <summary>
        /// 由聚类后的边得到聚类点
        /// </summary>
        /// <param name="edges"></param>
        /// <returns></returns>
        private List <ITinNode> GetNodeList(List <ITinEdge> edges)
        {
            List <ITinNode> nodes = new List <ITinNode>();

            for (int i = 0; i < edges.Count; i++)
            {
                ITinEdge currentEdge = edges[i];
                ITinNode fromNode    = currentEdge.FromNode;
                ITinNode toNode      = currentEdge.ToNode;
                if (!IsInNodes(fromNode, nodes))
                {
                    nodes.Add(fromNode);
                    m_nodeFlag[fromNode.Index - 1] = 0; //标记为待划分的点
                }
                if (!IsInNodes(toNode, nodes))
                {
                    nodes.Add(toNode);
                    m_nodeFlag[toNode.Index - 1] = 0;
                }
            }
            return(nodes);
        }
        public List <ITinEdge> GenerateITinEdgeLt(bool blnDataArea = true)
        {
            ITinAdvanced2 ptinadvanced2 = _pTinAdvanced2;
            var           ITinEdgeLt    = new List <ITinEdge>(ptinadvanced2.EdgeCount);

            for (int i = 0; i < ptinadvanced2.EdgeCount; i++)
            {
                ITinEdge ptinedge = ptinadvanced2.GetEdge(i + 1);
                if (blnDataArea == true)
                {
                    if (ptinedge.IsInsideDataArea)
                    {
                        ITinEdgeLt.Add(ptinedge);
                    }
                }
                else
                {
                    ITinEdgeLt.Add(ptinedge);
                }
            }
            _pTinEdgeLt = ITinEdgeLt;
            return(ITinEdgeLt);
        }
Example #9
0
 public void AddEdge(ITinEdge edge)
 {
     m_clusterEdge.Add(edge);
 }
Example #10
0
 public CEdge(ITinEdge pTinEdge, ITinNode pFrNode, ITinNode pToNode, bool isSetLength = false)
     : this(new CPoint(pFrNode), new CPoint(pToNode), isSetLength)
 {
     _pTinEdge = pTinEdge;
 }
Example #11
0
 public CEdge(ITinEdge pTinEdge, bool isSetLength = false)
     : this(pTinEdge, pTinEdge.FromNode, pTinEdge.ToNode, isSetLength)
 {
 }
 public void AddEdge(ITinEdge edge)
 {
     m_clusterEdge.Add(edge);
 }
Example #13
0
 /// <summary>
 /// 判断边edge是否在edgeList中
 /// </summary>
 /// <param name="edge"></param>
 /// <param name="edgeList"></param>
 /// <returns></returns>
 private bool IsInEdges(ITinEdge edge, List<ITinEdge> edgeList)
 {
     bool b = false;
     if (edgeList.Count == 0)
         return b;
     for (int i = 0; i < edgeList.Count; i++)
     {
         if (edge.Index == edgeList[i].Index)
         {
             b = true;
             break;
         }
     }
     return b;
 }