/*
         * Function: SstInit
         * Description:节点数据解析函数
         * Parameters:
         *      string sPath 文件路径
         *      int iNum    节点编号
         * Return Value:IfPlatform
         */
        private IfPlatform SstInit(string sLine, int iNum)
        {
            IfPlatform NewNode;
            string[] strSeg, strLink, strValue;
            int intDegree = 0, intlast;
            int intTarget;
            int i;

            //初始化新节点
            NewNode = new cNode(iNum);
            //切分字符串,变为各个子单元
            strSeg = sLine.Split(new char[] { SeperatorOut });                                
            intlast = strSeg.Length - 1;
            if (strSeg[intlast-linkOffset].Trim() != "")                                       
            {//生成节点基本信息
                strLink = strSeg[intlast - linkOffset].Split(new char[] { SeperatorIn });
                strValue = strSeg[intlast].Split(new char[] { SeperatorIn });
                intDegree = strLink.Length;
                for (i = 0; i < intDegree; i++)
                {
                    intTarget = Convert.ToInt32(strLink[i]) - intNumOffset;
                    if (iNum != intTarget)
                    {
                        NewNode.AddEdge(intTarget, Convert.ToInt32(strValue[i]));
                    }
                }
            }
            NewNode.Location = new Point(Convert.ToInt32(strSeg[xPos]), Convert.ToInt32(strSeg[yPos]));
            NewNode.ComCount = Convert.ToInt32(strSeg[ComPos]);
            return NewNode;
        }
Exemple #2
0
        /*
         * Function: BuileNetwork
         * Description:MATStrategy算法读取函数
         * Parameters:
         *      Byte[,] bytMatrix 从邻接矩阵生成cNet网络
         *      StyleSet pStyle 绘制样式集
         * Return Value:cNet
         */
        cNet BuileNetwork(Byte[,] bytMatrix)
		{
			cNet NewNet;
			IfPlatform NewNode;
			int intRow, intCol, i, j;

            intRow = bytMatrix.GetLength(0);
			intCol = bytMatrix.GetLength(1);
			
			NewNet = new cNet(intRow);
			for(i = 0; i < intRow; i++)
			{
				NewNode = new cNode(i);
				for(j = 0; j<intCol; j++)
				{
					if(bytMatrix[i, j] != 0)
					{
						NewNode.AddEdge(j, (double)bytMatrix[i, j]);
					}
				}
				NewNet.Network.Add(NewNode);
			}
            if (NewNet.intNumber == 0)
            {
                return null;
            }
            return NewNet;
		}