-
大小: 27KB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2021-06-01
- 語言: C#
- 標(biāo)簽: C#??圖??拓?fù)渑判?/b>??
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
namespace?Graph
{
????public?class?Graph
????{
????????int?numVertex;
????????int?maxVertex;
????????Vertex[]?vertexs;
????????int[]?adjMatrix;
????????public?Graph(int?maxvertex1)
????????{
????????????this.maxVertex?=?maxvertex1;
????????????vertexs=new?Vertex[maxVertex];
????????????adjMatrix=new?int[maxVertexmaxVertex];
????????????numVertex?=?0;
????????????for?(int?i?=?0;?i?????????????{
????????????????for?(int?j?=?0;?j?????????????????{
????????????????????adjMatrix[i?j]?=?0;
????????????????}
????????????}
????????}
????????public?void?AddVertex(string?label1)
????????{
????????????vertexs[numVertex++]?=?new?Vertex(label1);
????????}
????????public?void?AddEdge(int?start?int?end)
????????{
????????????adjMatrix[start?end]?=?1;
????????}
????????public?void?ShowVertex(int?v)
????????{
????????????Console.Write(?vertexs[v].label?+?“?“);
????????}
????????public?int?NoSuccessors()
????????{
????????????bool?isEdge??;
????????????for?(int?i?=?0;?i?????????????{
????????????????isEdge?=?false;
????????????????for?(int?j?=?0;?j?????????????????{
????????????????????if?(adjMatrix[i?j]?>?0)
????????????????????{
????????????????????????isEdge?=?true;
????????????????????????break;
????????????????????}
????????????????}
????????????????if?(!isEdge)
????????????????{
????????????????????return?i;
????????????????}
????????????}
????????????return?-1;
????????}
????????public?void?Delete(int?index)
????????{
????????????if?(index?!=?maxVertex?-?1)
????????????{
????????????????for?(int?i?=?index;?i?????????????????{
????????????????????vertexs[i]?=?vertexs[i?+?1];
????????????????}
????????????????for?(int?i?=?index;?i?????????????????{
????????????????????RemoveRow(index);
????????????????}
????????????????for?(int?i?=?0;?i?????????????????{
????????????????????RemoveCol(index);
????????????????}
????????????}
????????????maxVertex--;
????????}
????????private?void?RemoveCol(int?index)
????????{
????????????for?(int?i?=?0;?i?????????????{
????????????????adjMatrix[iindex]=adjMatrix[iindex+1];
????????????}
????????}
????????private?void?RemoveRow(int?index)
????????{
????????????for?(int?i?=?0;?i?????????????{
????????????????adjMatrix[indexi]=adjMatrix[index+1i];
????????????}
????????}
????????public?void?TopVertList()
????????{
????????????Stack?stack?=?new?Stack();
????????????while?(maxVertex?>?0)
????????????{
????????????????int?index=NoSuccessors();
????????????????if?(index?==?-1)
????????????????{
????????????????????Console.WriteLine(“節(jié)點包含環(huán)“);
????????????????????return;
????????????????}
????????????????stack.Push(vertexs[index].label);
?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????I.A....??????6656??2012-11-27?19:21??Graph\Graph\bin\Debug\Graph.exe
????I.A....?????19968??2012-11-27?19:21??Graph\Graph\bin\Debug\Graph.pdb
????I.A....?????11600??2012-11-27?19:22??Graph\Graph\bin\Debug\Graph.vshost.exe
????I.A....???????490??2010-03-17?22:39??Graph\Graph\bin\Debug\Graph.vshost.exe.manifest
????I.A....??????3256??2012-11-27?19:21??Graph\Graph\Graph.cs
????I.A....??????2550??2012-11-27?19:21??Graph\Graph\Graph.csproj
????I.A....??????5814??2012-11-27?19:21??Graph\Graph\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
????I.A....???????408??2012-11-27?19:22??Graph\Graph\obj\x86\Debug\Graph.csproj.FileListAbsolute.txt
????I.A....??????6656??2012-11-27?19:21??Graph\Graph\obj\x86\Debug\Graph.exe
????I.A....?????19968??2012-11-27?19:21??Graph\Graph\obj\x86\Debug\Graph.pdb
????I.A....???????744??2012-11-27?19:21??Graph\Graph\Program.cs
????I.A....??????1360??2012-11-27?10:51??Graph\Graph\Properties\AssemblyInfo.cs
????I.A....???????176??2012-11-27?19:21??Graph\Graph\TopologicalSort.cs
????I.A....???????348??2012-11-27?13:25??Graph\Graph\Vertex.cs
????I.A....???????857??2012-11-27?10:51??Graph\Graph.sln
????I.A..H.?????16896??2012-11-27?19:43??Graph\Graph.suo
????I..D...?????????0??2012-11-27?10:51??Graph\Graph\obj\x86\Debug\TempPE
????I..D...?????????0??2012-11-27?19:21??Graph\Graph\obj\x86\Debug
????I..D...?????????0??2012-11-27?19:21??Graph\Graph\bin\Debug
????I..D...?????????0??2012-11-27?10:51??Graph\Graph\obj\x86
????I..D...?????????0??2012-11-27?10:51??Graph\Graph\bin
????I..D...?????????0??2012-11-27?10:51??Graph\Graph\obj
????I..D...?????????0??2012-11-27?10:51??Graph\Graph\Properties
????I..D...?????????0??2012-11-27?18:19??Graph\Graph
????I..D...?????????0??2012-11-27?10:51??Graph
-----------?---------??----------?-----??----
????????????????97747????????????????????25
- 上一篇:C#與TwinCAT通訊
- 下一篇:模擬退火算法C#源碼+
評論
共有 條評論
相關(guān)資源
- C#解析HL7消息的庫135797
- C# OCR數(shù)字識別實例,采用TessnetOcr,對
- 考試管理系統(tǒng) - C#源碼
- asp.net C#購物車源代碼
- C#實時網(wǎng)絡(luò)流量監(jiān)聽源碼
- C#百度地圖源碼
- Visual C#.2010從入門到精通配套源程序
- C# 軟件版本更新
- C#屏幕軟鍵盤源碼,可以自己定制界面
- 智慧城市 智能家居 C# 源代碼
- c#獲取mobile手機的IMEI和IMSI
- C#實現(xiàn)簡單QQ聊天程序
- 操作系統(tǒng) 模擬的 歡迎下載 C#版
- C#寫的計算機性能監(jiān)控程序
- 用C#實現(xiàn)郵件發(fā)送,有點類似于outlo
- MVC model層代碼生成器 C#
- c#小型圖書銷售系統(tǒng)
- C# Socket Server Client 通訊應(yīng)用 完整的服
- c# winform 自動登錄 百度賬戶 源代碼
- C#編寫的16進(jìn)制計算器
- C#TCP通信協(xié)議
- C# 數(shù)據(jù)表(Dataset)操作 合并 查詢一
- C#語音識別系統(tǒng)speechsdk51,SpeechSDK51L
- 數(shù)據(jù)庫備份還原工具1.0 C# 源碼
-
[免費]xm
lDocument 節(jié)點遍歷C# - EQ2008LEDc#開發(fā)實例
- DirectX.Capturec# winform 操作攝像頭錄像附
- c# 實現(xiàn)的最大最小距離方法對鳶尾花
- C#版保齡球記分代碼
- C#自定義控件