static void Main(string[] args) { //Membaca File dan Inisialisasi Graph Console.WriteLine("============================== Penyusunan Mata Kuliah dengan DFS dan BFS =============================="); Console.WriteLine("================================== Oleh 13516098, 13516104, 13516152 =================================="); Console.WriteLine(""); Console.WriteLine("Sebelum memasukan nama file, pastikan file sudah disimpan di dalam folder \nTubesDuaStima/TopologicalSort/TopologicalSort/bin/Debug"); Console.Write("Nama file : "); string s = Console.ReadLine(); ReadFile R = new ReadFile(s.Trim()); Graph G = new Graph(); G = R.OpenFile(); R.GeneratePostReq(G); G.Draw(); Console.WriteLine("HASIL TOPOLOGICAL SORTING"); Console.WriteLine("========================="); //Menggambar DFS DFS dfs = new DFS(G); dfs.Execute(G); //Menggambar BFS BFS bfs = new BFS(G); bfs.Execute(G); Console.WriteLine("\n====================="); Console.WriteLine("Press any key to exit "); Console.ReadLine(); }
public static void main() { //create a form System.Windows.Forms.Form form = new System.Windows.Forms.Form(); //create a viewer object Microsoft.Glee.GraphViewerGdi.GViewer viewer = new Microsoft.Glee.GraphViewerGdi.GViewer(); //create a graph object Microsoft.Glee.Drawing.Graph graph = new Microsoft.Glee.Drawing.Graph("graph"); //create the graph content CoursePlan coursePlan = new CoursePlan("Daftar Kuliah.txt"); coursePlan.Print(); foreach (KeyValuePair <string, Subject> entry in coursePlan.subjects) { Subject subject = entry.Value; foreach (string element in subject.preq_of) { graph.AddEdge(subject.name, element); } } DFS resultDFS = new DFS(coursePlan.subjects); resultDFS.Print(); Console.WriteLine(); BFS resultBFS = new BFS(coursePlan.subjects); resultBFS.Print(); /*string strNode1 = "Circle"; * string strNode2 = "Home"; * string strNode3 = "Diamond"; * string strNode4 = "Standard"; * * graph.AddEdge(strNode1, strNode2); * graph.AddEdge(strNode2, strNode1); * graph.AddEdge(strNode2, strNode2); * graph.AddEdge(strNode1, strNode3); * graph.AddEdge(strNode1, strNode4); * graph.AddEdge(strNode4, strNode1);*/ //graph.AddEdge(strNode2, "Node 0"); //for (int i = 0; i & lt; 3; i++) graph.AddEdge("Node " + i.ToString(), "Node " + (i + 1).ToString()); //for (int i = 0; i & lt; 3; i++) graph.AddEdge("Node " + (i + 1).ToString(), "Node " + i.ToString()); //bind the graph to the viewer viewer.Graph = graph; //associate the viewer with the form form.SuspendLayout(); viewer.Dock = System.Windows.Forms.DockStyle.Fill; form.Controls.Add(viewer); form.ResumeLayout(); //show the form form.ShowDialog(); }