public static void main() { //create a form System.Windows.Forms.Form form = new System.Windows.Forms.Form(); form.BackColor = System.Drawing.Color.Black; form.Size = new System.Drawing.Size(1000, 600); //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"); graph.GraphAttr.Backgroundcolor = Microsoft.Glee.Drawing.Color.LavenderBlush; //create the graph content CoursePlan coursePlan = new CoursePlan(filename); 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); } } //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(); // print to console //DFS resultDFS = new DFS(coursePlan.subjects); //resultDFS.Print(); }
private void module_bfs_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Console.WriteLine("this is bfs module"); if (!page_bfs.IsVisible) { page_default.Visibility = Visibility.Hidden; page_input.Visibility = Visibility.Hidden; page_list.Visibility = Visibility.Hidden; page_dfs.Visibility = Visibility.Hidden; page_bfs.Visibility = Visibility.Visible; page_info.Visibility = Visibility.Hidden; HL01.Visibility = Visibility.Hidden; HL02.Visibility = Visibility.Hidden; HL03.Visibility = Visibility.Hidden; HL04.Visibility = Visibility.Visible; HL05.Visibility = Visibility.Hidden; } else if (page_bfs.IsVisible) { page_default.Visibility = Visibility.Visible; page_bfs.Visibility = Visibility.Hidden; HL04.Visibility = Visibility.Hidden; } list_subject.Visibility = Visibility.Hidden; DFS_plan.Visibility = Visibility.Hidden; Info_box.Visibility = Visibility.Hidden; rtb_input.Visibility = Visibility.Hidden; enter_button1.Visibility = Visibility.Hidden; string filename = ListSubjectViewer.filename; CoursePlan coursePlan = new CoursePlan(filename); BFS bfsResult = new BFS(coursePlan.subjects); BFS_plan.Visibility = Visibility.Visible; BFS_plan.Text = bfsResult.get_name_list(); BFSViewer.main(); }
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(); }
public static string filename;// = "../../../../" + "Daftar Kuliah.txt"; public static void main() { //create a form System.Windows.Forms.Form form = new System.Windows.Forms.Form(); form.Size = new System.Drawing.Size(1000, 600); //create a viewer object Microsoft.Glee.GraphViewerGdi.GViewer viewer = new Microsoft.Glee.GraphViewerGdi.GViewer(); viewer.OutsideAreaBrush = Brushes.LightCoral; //create a graph object Microsoft.Glee.Drawing.Graph graph = new Microsoft.Glee.Drawing.Graph("graph"); graph.GraphAttr.Backgroundcolor = Microsoft.Glee.Drawing.Color.LightCoral; //create the graph content CoursePlan coursePlan = new CoursePlan(filename); Subject tempSub = new Subject(); BFS bfsResult = new BFS(coursePlan.subjects); CoursePlan tempCourse = new CoursePlan(filename); string temp = "1. " + bfsResult.result[1][0]; List <string> convert = new List <string>(); foreach (KeyValuePair <int, List <string> > entry in bfsResult.result) { foreach (string x in entry.Value) { convert.Add(x); } } for (int i = 0; i < convert.Count - 1; i++) { tempSub = tempCourse.subjects[convert[i]]; foreach (string x in tempSub.preq_of) { int index = convert.IndexOf(x) + 1; graph.AddEdge(((i + 1).ToString() + ". " + convert[i]), (index.ToString() + ". " + x)); } } int j = 1; foreach (KeyValuePair <int, List <string> > entry in bfsResult.result) { foreach (string tempp in entry.Value) { Microsoft.Glee.Drawing.Node n = graph.FindNode(j.ToString() + ". " + tempp); switch (entry.Key % 5) { case 1: { n.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.MidnightBlue; n.Attr.Fontcolor = Microsoft.Glee.Drawing.Color.LavenderBlush; break; } case 2: { n.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.MediumBlue; n.Attr.Fontcolor = Microsoft.Glee.Drawing.Color.LavenderBlush; break; } case 3: { n.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.RoyalBlue; break; } case 4: { n.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.DodgerBlue; break; } default: { n.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.SkyBlue; break; } } j++; } } //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(); }