예제 #1
0
        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();
        }
예제 #2
0
        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();
        }