/// <summary>
 /// 初始化SparseMatrix类的新实例
 /// </summary>
 /// <param name="rows">稀疏矩阵的行数</param>
 /// <param name="cols">稀疏矩阵的列数</param>
 public SparseMatrix(int rows, int cols)
 {
     if (rows <= 0 || cols <= 0)
         throw new Exception("数组行数或列数小于等于零.");
     this.rows = rows;
     this.cols = cols;
     this.lst = new SLinkList<Triple>();
 }
 static void Main(string[] args)
 {
     ILinearList<string> lst = new SLinkList<string>();
     lst.Insert(0, "a1");
     lst.Insert(1, "a2");
     lst.Insert(2, "a3");
     lst.Remove(1);
     Console.WriteLine(lst.Length);
     for (int i = 0; i < lst.Length; i++)
     {
         Console.WriteLine(lst[i]);
     }
 }
        /// <summary>
        /// �õ���ͨ����
        /// </summary>
        /// <returns>��ͨ����</returns>
        public string ConnectedComponent()
        {
            string Result = string.Empty;
            SLinkList<string> lst = new SLinkList<string>();

            for (int i = 0; i < vertexCount; i++)
                vertexList[i].Visited = false;

            for (int i = 0; i < vertexCount; i++)
            {
                if (vertexList[i].Visited == false)
                {
                    Result = string.Empty;
                    DFS(i, ref Result);//��������������������ͨͼ����ͨ����
                    lst.InsertAtRear(Result);
                }
            }
            Result = string.Empty;
            for (int i = 0; i < lst.Length; i++)
            {
                Result += "��" + i.ToString() + "����ͨ����Ϊ:\n" + lst[i];
            }
            return Result;
        }