示例#1
0
        private void InitializeGraph(String[] node)
        {
            try
            {
                viewer = new Microsoft.Glee.GraphViewerGdi.GViewer();

                //create a graph object
                graph = new Microsoft.Glee.Drawing.Graph("graph");

                String[] s;

                //inisialisasi
                TotalNode = Int32.Parse(node[0]);
                vertex    = new List <int> [TotalNode + 1];
                visited   = new bool[TotalNode + 1];
                Node n;
                for (int i = 1; i <= TotalNode; i++)
                {
                    vertex[i] = new List <int>();
                }

                //Menampilkan visualisasi graf
                for (int i = 1; i < node.Length; i++)
                {
                    s = node[i].Split(' ');
                    graph.AddEdge(s[0], s[1]);
                    //Memasukkan graf kedalam list ketetanggaannya
                    vertex[Int32.Parse(s[0])].Add(Int32.Parse(s[1]));
                    vertex[Int32.Parse(s[1])].Add(Int32.Parse(s[0]));

                    n = graph.FindNode(s[0]);
                    n.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.DarkSlateGray;
                    n.Attr.Shape     = Microsoft.Glee.Drawing.Shape.Circle;
                    n = graph.FindNode(s[1]);
                    n.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.DarkSlateGray;
                    n.Attr.Shape     = Microsoft.Glee.Drawing.Shape.Circle;
                }

                graph.GraphAttr.EdgeAttr.ArrowHeadAtTarget = ArrowStyle.None;
                //bind the graph to the viewer
                viewer.Graph = graph;

                //associate the viewer with the form
                //grafPanel.Controls.Remove(viewer);
                grafPanel.Controls.Clear();
                grafPanel.SuspendLayout();
                viewer.Dock = System.Windows.Forms.DockStyle.Fill;
                grafPanel.Controls.Add(viewer);
                grafPanel.ResumeLayout();
            }
            catch (FormatException ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }
示例#2
0
        public void Draw()
        {
            UndirectedGraph <Vertex, QuickGraph.Edge <Vertex> > mG
                = new UndirectedGraph <Vertex, QuickGraph.Edge <Vertex> >();

            List <Vertex> .Enumerator etV = mGraph.mVertices.GetEnumerator();
            while (etV.MoveNext())
            {
                mG.AddVertex(etV.Current);
            }

            List <Edge> .Enumerator etE = mGraph.mEdges.GetEnumerator();
            while (etE.MoveNext())
            {
                QuickGraph.Edge <Vertex> e = new Edge <Vertex>(etE.Current.mVertexA, etE.Current.mVertexB);
                mG.AddEdge(e);
            }

            Console.WriteLine("QUICK GRAPH FORMAT:");
            Console.WriteLine(mG.VertexCount);
            Console.WriteLine(mG.EdgeCount);

            /*
             * var graphviz = new GraphvizAlgorithm<Vertex, Edge<Vertex>>(mG);
             * string output = graphviz.Generate(new FileDotEngine(), "graph");
             *
             * Console.WriteLine("OUTPUT");
             * Console.WriteLine(output);
             *
             * // Process drawProcess = new Process();
             * Process.Start("dot","-Tpng graph.dot > graph.png");
             */

            var populator = GleeGraphUtility.Create <Vertex, Edge <Vertex> >(mG);

            populator.Compute();
            Microsoft.Glee.Drawing.Graph gleeG = populator.GleeGraph;

            //create a viewer object
            Microsoft.Glee.GraphViewerGdi.GViewer viewer = new Microsoft.Glee.GraphViewerGdi.GViewer();
            //create a form
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();

            //bind the graph to the viewer
            viewer.Graph = gleeG;

            //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();
        }
示例#3
0
        static void buatMap(string mapLoc) //Membuat representasi peta dalam graf dan linkedlist
        {
            //Inisialisasi Graph
            //create a form

            //create a viewer object
            viewer = new Microsoft.Glee.GraphViewerGdi.GViewer();
            //create a graph object
            graph = new Microsoft.Glee.Drawing.Graph("graph");

            //Inisialisasi variable static
            file    = new System.IO.StreamReader(@mapLoc);
            N       = Convert.ToInt32(file.ReadLine());
            nodeVal = new int[N + 1];
            visited = new bool[N + 1];
            pathArr = new int[N + 1];
            //ALGORITMA

            //inisialiasi ketetanggaan seluruh node dan nilai visited
            myList = new LinkedList <int> [N + 1];
            for (int i = 1; i <= N; i++)
            {
                visited[i] = false;
                myList[i]  = new LinkedList <int>();
            }

            //Input
            string[] inp = new string[2];
            int      temp1, temp2;

            for (int i = 0; i < N - 1; i++)
            {
                inp   = file.ReadLine().Split();
                temp1 = int.Parse(inp[0]);
                temp2 = int.Parse(inp[1]);

                //Mengisi ketetanggaan kedua node
                myList[temp1].AddLast(temp2);
                myList[temp2].AddLast(temp1);

                //Membuat Graph
                string tempst1 = temp1.ToString();
                string tempst2 = temp2.ToString();
                graph.AddEdge(tempst1, tempst2);
            }
            //Inisialisasi nilai awal simpul dengan nol
            for (int i = 1; i <= N; i++)
            {
                nodeVal[i] = 0;
            }
            giveNodeValue(1, 0);
        }
示例#4
0
        //отрисовка графа
        private void DrawGraph(int currentTop)
        {
            this.GraphPanel.Controls.Clear();
            Microsoft.Glee.GraphViewerGdi.GViewer viewer = new Microsoft.Glee.GraphViewerGdi.GViewer();
            viewer.AsyncLayout = false;
            viewer.AutoScroll  = true;
            nodes = new string[nodesCount];
            for (int i = 0; i < nodesCount; ++i)
            {
                nodes[i] = (i + 1).ToString();
            }

            graph = new Microsoft.Glee.Drawing.Graph("Graph");
            for (int i = 0; i < nodesCount; ++i)
            {
                for (int j = 0; j < nodesCount; ++j)
                {
                    if (adjancyMatrix[i, j] != 0)
                    {
                        graph.AddEdge(nodes[i], "" /*adjancyMatrix[i, j].ToString()*/, nodes[j]);
                    }
                }
            }
            for (int i = 0; i < nodesCount; ++i)
            {
                Microsoft.Glee.Drawing.Node currentNode = graph.FindNode(nodes[i]);
                if (i == currentTop)
                {
                    currentNode.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Green;
                }
                else
                {
                    currentNode.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Yellow;
                }
                currentNode.Attr.Shape = Microsoft.Glee.Drawing.Shape.DoubleCircle;
            }
            Microsoft.Glee.GraphViewerGdi.GraphRenderer renderer = new Microsoft.Glee.GraphViewerGdi.GraphRenderer(graph);
            viewer.Graph = graph;
            this.GraphPanel.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            this.GraphPanel.Controls.Add(viewer);
            this.GraphPanel.ResumeLayout();

            //Bitmap graphImage = new Bitmap(GraphPanel.Width, GraphPanel.Height);
            //renderer.Render(graphImage);
            //GraphPanel.Image = graphImage;
        }
示例#5
0
        public MainWindow()
        {
            InitializeComponent();

            _wTimer = new Timer();
            _wTimer.Interval = 500;
            _wTimer.Tick += new EventHandler(wTimer_Tick);

            _mainController = new MainController();
            _viewer = new Microsoft.Glee.GraphViewerGdi.GViewer();
            RenderDataGridGraph();
            //            RenderViewGraph();
            RenderDataGridPersons();
            RenderAlgorithm();
            RenderLaunchMode();
            RenderTableOfLaunch();
        }
        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();
        }
示例#7
0
        // FUNCTION TO DO LOAD GRAPH AND RUN DFS:
        public static void runDFS(Form1 f1)
        {
            defaultG = new Graph("graph");
            if (graphForm.IsDisposed)
            {
                Console.WriteLine(graphForm == null);
                graphForm = new Form();
                viewer    = new Microsoft.Glee.GraphViewerGdi.GViewer();
            }
            StreamReader sr    = new StreamReader(@f1.getFileURL());
            string       Rumah = sr.ReadLine();

            jmlRumah = Int32.Parse(Rumah);

            buildTree(ref sr, jmlRumah);

            // DFS
            arrive  = new long[jmlRumah + 1];
            leave   = new long[jmlRumah + 1];
            visited = new bool[jmlRumah + 1];

            DFS(1, ref tree);

            // COLOR THE ROOT (1) WITH SEAGREEN COLOR
            Microsoft.Glee.Drawing.Node n1 = defaultG.FindNode("1");
            n1.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.SeaGreen;
            // Make Root a double-circled vertex just for emphasis, hehe:
            n1.Attr.Shape = Microsoft.Glee.Drawing.Shape.DoubleCircle;

            // SHOWING THE GRAPH:
            // Bind the graph to the viewer
            viewer.Graph = defaultG;

            // Associate the viewer with the created form
            graphForm.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            graphForm.Controls.Add(viewer);
            graphForm.ResumeLayout();
            graphForm.Refresh();

            // Show the form as a new window, BUT not locked there!
            graphForm.Show();
        }
示例#8
0
    public void GambarPeta()
    //Method menggabarkan peta penyebaran atribut graf pada form baru
    {
        System.Windows.Forms.Form             peta = new System.Windows.Forms.Form();
        Microsoft.Glee.GraphViewerGdi.GViewer view = new Microsoft.Glee.GraphViewerGdi.GViewer();
        Microsoft.Glee.Drawing.Graph          map  = new Microsoft.Glee.Drawing.Graph("Peta Penyebaran Virus");

        Dictionary <string, Graph> .KeyCollection keys = this.graf.Keys;
        foreach (string node1 in keys)
        {
            if (graf[node1].GetNEdge() == 0)
            {
                map.AddNode(node1);
            }
            else
            {
                foreach (string node2 in graf[node1].GetEdge())
                {
                    map.AddEdge(node1, node2);
                }
                if (graf[node1].GetDayInf() != -1)
                {
                    Microsoft.Glee.Drawing.Node temp = map.FindNode(node1);
                    temp.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Red;
                }
            }
        }

        //bind the graph to the viewer
        view.Graph = map;

        //associate the viewer with the form
        peta.SuspendLayout();
        view.Dock = System.Windows.Forms.DockStyle.Fill;
        peta.Controls.Add(view);
        peta.ResumeLayout();
        peta.Text          = "Peta Penyebaran Virus";
        peta.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

        //show the form
        peta.ShowDialog();
    }
        private void ShowGraphDialog(Microsoft.Glee.Drawing.Graph graph)
        {
            //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();

            //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();
        }
示例#10
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();
        }
示例#11
0
        private int critical_path()
        {
            ////////////////////////////////////////////////////////////////////////////////////
            graph = new Microsoft.Glee.Drawing.Graph("graph");
            DataTable task = new DataTable("task");

            DataColumn task_name = new DataColumn("task_name");

            task_name.DataType = Type.GetType("System.String");

            DataColumn task_duration = new DataColumn("task_duration");

            task_duration.DataType = Type.GetType("System.Int32");

            DataColumn task_duration_type = new DataColumn("task_duration_type");

            task_duration_type.DataType = Type.GetType("System.String");

            DataColumn task_starting_time = new DataColumn("task_starting_time");

            task_starting_time.DataType = Type.GetType("System.DateTime");

            DataColumn task_finishing_time = new DataColumn("task_finishing_time");

            task_finishing_time.DataType = Type.GetType("System.DateTime");


            task.Columns.Add(task_name);
            task.Columns.Add(task_duration);
            task.Columns.Add(task_duration_type);
            task.Columns.Add(task_starting_time);
            task.Columns.Add(task_finishing_time);
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            DataTable Tas_dep = new DataTable("Tas_dep");

            DataColumn Tas_dep_t = new DataColumn("Tas_dep_t");

            Tas_dep_t.DataType = Type.GetType("System.String");

            DataColumn Tas_dep_tp = new DataColumn("Tas_dep_tp");

            Tas_dep_tp.DataType = Type.GetType("System.String");

            Tas_dep.Columns.Add(Tas_dep_t);
            Tas_dep.Columns.Add(Tas_dep_tp);
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            DataTable flip = new DataTable("flip");

            DataColumn fatherr = new DataColumn("fatherr");

            fatherr.DataType = Type.GetType("System.String");

            DataColumn sonn = new DataColumn("sonn");

            sonn.DataType = Type.GetType("System.String");

            flip.Columns.Add(fatherr);
            flip.Columns.Add(sonn);
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            DataTable dep = new DataTable("dep");

            DataColumn f = new DataColumn("f");

            Tas_dep_t.DataType = Type.GetType("System.String");

            DataColumn s = new DataColumn("s");

            Tas_dep_tp.DataType = Type.GetType("System.String");

            dep.Columns.Add(f);
            dep.Columns.Add(s);
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            ods.Tables.Add(task);
            ods.Tables.Add(Tas_dep);
            ods.Tables.Add(flip);
            ods.Tables.Add(dep);
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            graph.CleanNodes();
            for (int k = 0; k < ods.Tables[0].Rows.Count; k++)
            {
                ods.Tables[0].Rows.RemoveAt(k);
            }
            for (int k = 0; k < ods.Tables[1].Rows.Count; k++)
            {
                ods.Tables[1].Rows.RemoveAt(k);
            }
            for (int k = 0; k < Program.ods.Tables[0].Rows.Count; k++)
            {
                string name = Program.ods.Tables[0].Rows[k][0].ToString();
                int    dur  = int.Parse(Program.ods.Tables[0].Rows[k][1].ToString());
                string type = Program.ods.Tables[0].Rows[k][2].ToString();
                switch (type)
                {
                case "Month": { dur = dur * 30; } break;

                case "Hour":
                {
                    double duration_ = ((double)dur / Program.number_of_working_hours);
                    dur = (int)Math.Ceiling(duration_);
                }
                break;

                case "Week": { dur = dur * 7; } break;
                }
                string   d1  = Program.ods.Tables[0].Rows[k][3].ToString();
                string   d2  = Program.ods.Tables[0].Rows[k][4].ToString();
                string[] d11 = d1.Split(' ');

                DateTime st = DateTime.Parse(d11[0]);

                //DateTime fn= null;
                ods.Tables["task"].Rows.Add(name, dur, type, st);
            }
            for (int k = 0; k < Program.ods.Tables[3].Rows.Count; k++)
            {
                string col1 = Program.ods.Tables[3].Rows[k][0].ToString();
                string col2 = Program.ods.Tables[3].Rows[k][1].ToString();
                ods.Tables[1].Rows.Add(col1, col2);
            }

            for (int q = 0; q < Tas_dep.Rows.Count; q++)
            {
                flip.Rows.Add(null, null);
                flip.Rows[q][0] = Tas_dep.Rows[q][1];
                flip.Rows[q][1] = Tas_dep.Rows[q][0];
            }

            for (int q = 0; q < flip.Rows.Count; q++)
            {
                dep.Rows.Add(null, null);
                dep.Rows[q][0] = flip.Rows[q][0];
                dep.Rows[q][1] = flip.Rows[q][1];
            }

            for (int q = 0; q < task.Rows.Count; q++)//for father
            {
                int y = 0;
                for (int w = 0; w < flip.Rows.Count; w++)//if there is father
                {
                    if (task.Rows[q][0] == flip.Rows[w][1])
                    {
                        y = 1;
                    }
                }
                if (y != 1)
                {
                    dep.Rows.Add(null, task.Rows[q][0]);
                }
                y = 0;
            }
            for (int q = 0; q < task.Rows.Count; q++)//for son
            {
                int y = 0;
                for (int w = 0; w < flip.Rows.Count; w++)//if there is son
                {
                    if (task.Rows[q][0] == flip.Rows[w][0])
                    {
                        y = 1;
                    }
                }
                if (y != 1)
                {
                    dep.Rows.Add(task.Rows[q][0], null);
                }
                y = 0;
            }
            Console.WriteLine("this is the dep that u are going to use\n");
            for (int q = 0; q < dep.Rows.Count; q++)
            {
                Console.WriteLine("fa:{0}  son:{1}\n", dep.Rows[q][0], dep.Rows[q][1]);
            }


            int n;

            n = ods.Tables[0].Rows.Count;
            int i;

            init(n);
            net_work[0].flag        = 1;
            net_work[n + 1].flag    = 1;
            net_work[0].early_start = 0;
            net_work[0].early_end   = 0;
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            for (i = 1; i < n + 1; i++)
            {
                int x = int.Parse(ods.Tables[0].Rows[i - 1][1].ToString());
                net_work[i].value = x;
            }
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            int m;

            m = dep.Rows.Count;
            int fa = new int(), son = new int();

            for (i = 0; i < m; i++)
            {
                string sonName, sonNameToCheck, fatherName, fatherNameToCheck;
                //for the father
                for (int j = 0; j < n; j++)
                {
                    fatherName        = dep.Rows[i][0].ToString();
                    fatherNameToCheck = ods.Tables[0].Rows[j][0].ToString();
                    if (fatherName == "")
                    {
                        fa = 0;
                        break;
                    }

                    if (fatherName == fatherNameToCheck)
                    {
                        fa = j + 1;
                        break;
                    }// comparison for parent to find its number from a string
                }

                // for the son
                for (int j = 0; j < n; j++)
                {
                    sonName        = dep.Rows[i][1].ToString();
                    sonNameToCheck = ods.Tables[0].Rows[j][0].ToString();
                    if (sonName == "")
                    {
                        son = n + 1;
                        break;
                    }
                    if (sonName == sonNameToCheck)
                    {
                        son = j + 1;
                        break;
                    }
                }

                //fa = int.Parse(ods.Tables[1].Rows[i][0].ToString());
                //son = int.Parse(ods.Tables[1].Rows[i][1].ToString());
                add_node(fa, son);
            }
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            for (int z = 0; z < n + 1; z++)
            {
                Console.WriteLine("value:{0}\n", net_work[z].value);
            }
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            topological_order();
            show_item(n);
            net_work[n + 1].last_start = net_work[n + 1].early_start;
            net_work[n + 1].last_end   = net_work[n + 1].early_end;
            inverse_topological_order(n + 1);
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // find_critical_path(0);
            show_item(n);

            //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
            //create the graph content
            //graph.AddEdge("Start", "T1");
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            for (i = 0; i < m; i++)
            {
                if (dep.Rows[i][0].ToString() == "")
                {
                    graph.AddEdge("start", dep.Rows[i][1].ToString());
                    continue;
                }
                if (dep.Rows[i][1].ToString() == "")
                {
                    graph.AddEdge(dep.Rows[i][0].ToString(), "end");
                    continue;
                }

                graph.AddEdge(dep.Rows[i][0].ToString(), dep.Rows[i][1].ToString()).Attr.Color = Microsoft.Glee.Drawing.Color.Green;
            }
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //graph.AddEdge("Start", "End").Attr.Color = Microsoft.Glee.Drawing.Color.Green;
            //graph.FindNode("start").Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Magenta;

            find_critical_path(0);
            //graph.FindNode("T1").Attr.Fillcolor = Microsoft.Glee.Drawing.Color.MistyRose;
            //Microsoft.Glee.Drawing.Node c = graph.FindNode("End");
            //c.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.PaleGreen;
            //c.Attr.Shape = Microsoft.Glee.Drawing.Shape.Diamond;
            //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();

            return(0);
        }
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Cluster_Graph));
     this.addButton = new System.Windows.Forms.Button();
     this.textBox4 = new System.Windows.Forms.TextBox();
     this.drawButton = new System.Windows.Forms.Button();
     this.comboBox1 = new System.Windows.Forms.ComboBox();
     this.groupBox1 = new System.Windows.Forms.GroupBox();
     this.gViewer = new Microsoft.Glee.GraphViewerGdi.GViewer();
     this.groupBox1.SuspendLayout();
     this.SuspendLayout();
     //
     // addButton
     //
     this.addButton.ForeColor = System.Drawing.Color.Black;
     this.addButton.Location = new System.Drawing.Point(7, 34);
     this.addButton.Margin = new System.Windows.Forms.Padding(4);
     this.addButton.Name = "addButton";
     this.addButton.Size = new System.Drawing.Size(269, 38);
     this.addButton.TabIndex = 3;
     this.addButton.Text = "Generate Clusters";
     this.addButton.UseVisualStyleBackColor = true;
     this.addButton.Click += new System.EventHandler(this.addButton_Click);
     //
     // textBox4
     //
     this.textBox4.ForeColor = System.Drawing.Color.Black;
     this.textBox4.Location = new System.Drawing.Point(11, 149);
     this.textBox4.Margin = new System.Windows.Forms.Padding(4);
     this.textBox4.Multiline = true;
     this.textBox4.Name = "textBox4";
     this.textBox4.ReadOnly = true;
     this.textBox4.ScrollBars = System.Windows.Forms.ScrollBars.Both;
     this.textBox4.Size = new System.Drawing.Size(269, 559);
     this.textBox4.TabIndex = 4;
     //
     // drawButton
     //
     this.drawButton.ForeColor = System.Drawing.Color.Black;
     this.drawButton.Location = new System.Drawing.Point(176, 93);
     this.drawButton.Margin = new System.Windows.Forms.Padding(4);
     this.drawButton.Name = "drawButton";
     this.drawButton.Size = new System.Drawing.Size(100, 39);
     this.drawButton.TabIndex = 5;
     this.drawButton.Text = "Show";
     this.drawButton.UseVisualStyleBackColor = true;
     this.drawButton.Click += new System.EventHandler(this.drawButton_Click);
     //
     // comboBox1
     //
     this.comboBox1.Enabled = false;
     this.comboBox1.ForeColor = System.Drawing.Color.Black;
     this.comboBox1.FormattingEnabled = true;
     this.comboBox1.Items.AddRange(new object[] {
     "connected graph",
     "Direct Graph"});
     this.comboBox1.Location = new System.Drawing.Point(7, 101);
     this.comboBox1.Margin = new System.Windows.Forms.Padding(4);
     this.comboBox1.Name = "comboBox1";
     this.comboBox1.Size = new System.Drawing.Size(161, 24);
     this.comboBox1.TabIndex = 6;
     this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
     //
     // groupBox1
     //
     this.groupBox1.Controls.Add(this.addButton);
     this.groupBox1.Controls.Add(this.textBox4);
     this.groupBox1.Controls.Add(this.comboBox1);
     this.groupBox1.Controls.Add(this.drawButton);
     this.groupBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.groupBox1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
     this.groupBox1.Location = new System.Drawing.Point(12, 12);
     this.groupBox1.Name = "groupBox1";
     this.groupBox1.Size = new System.Drawing.Size(296, 729);
     this.groupBox1.TabIndex = 7;
     this.groupBox1.TabStop = false;
     this.groupBox1.Text = "Cluster Generation";
     //
     // gViewer
     //
     this.gViewer.AsyncLayout = true;
     this.gViewer.AutoScroll = true;
     this.gViewer.BackwardEnabled = false;
     this.gViewer.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
     this.gViewer.ForwardEnabled = false;
     this.gViewer.Graph = null;
     this.gViewer.Location = new System.Drawing.Point(325, 12);
     this.gViewer.MouseHitDistance = 0.05D;
     this.gViewer.Name = "gViewer";
     this.gViewer.NavigationVisible = true;
     this.gViewer.PanButtonPressed = false;
     this.gViewer.SaveButtonVisible = true;
     this.gViewer.Size = new System.Drawing.Size(947, 726);
     this.gViewer.TabIndex = 8;
     this.gViewer.Visible = false;
     this.gViewer.ZoomF = 1D;
     this.gViewer.ZoomFraction = 0.5D;
     this.gViewer.ZoomWindowThreshold = 0.05D;
     //
     // Form1
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
     this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     this.BackColor = System.Drawing.Color.White;
     this.ClientSize = new System.Drawing.Size(1284, 750);
     this.Controls.Add(this.gViewer);
     this.Controls.Add(this.groupBox1);
     this.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
     this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.Margin = new System.Windows.Forms.Padding(4);
     this.Name = "Form1";
     this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
     this.Text = "Twitter Classification Clustering";
     this.groupBox1.ResumeLayout(false);
     this.groupBox1.PerformLayout();
     this.ResumeLayout(false);
 }
示例#13
0
 public frmDiagram()
 {
     InitializeComponent();
     viewer = new Microsoft.Glee.GraphViewerGdi.GViewer();
     graph  = new Graph("diagram");
 }
示例#14
0
        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();
        }
示例#15
0
        //отрисовка графа
        private void DrawGraph(int currentTop)
        {
            this.GraphPanel.Controls.Clear();
            Microsoft.Glee.GraphViewerGdi.GViewer viewer = new Microsoft.Glee.GraphViewerGdi.GViewer();
            viewer.AsyncLayout = false;
            viewer.AutoScroll = true;
            nodes = new string[nodesCount];
            for (int i = 0; i < nodesCount; ++i)
            {
                nodes[i] = (i + 1).ToString();
            }

            graph = new Microsoft.Glee.Drawing.Graph("Graph");
            for (int i = 0; i < nodesCount; ++i)
            {
                for (int j = 0; j < nodesCount; ++j)
                {
                    if (adjancyMatrix[i, j] != 0)
                    {
                        graph.AddEdge(nodes[i], ""/*adjancyMatrix[i, j].ToString()*/, nodes[j]);
                    }
                }
            }
            for (int i = 0; i < nodesCount; ++i)
            {
                Microsoft.Glee.Drawing.Node currentNode = graph.FindNode(nodes[i]);
                if (i == currentTop)
                {
                    currentNode.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Green;
                }
                else
                {
                    currentNode.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Yellow;
                }
                currentNode.Attr.Shape = Microsoft.Glee.Drawing.Shape.DoubleCircle;
            }
            Microsoft.Glee.GraphViewerGdi.GraphRenderer renderer = new Microsoft.Glee.GraphViewerGdi.GraphRenderer(graph);
            viewer.Graph = graph;
            this.GraphPanel.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            this.GraphPanel.Controls.Add(viewer);
            this.GraphPanel.ResumeLayout();

            //Bitmap graphImage = new Bitmap(GraphPanel.Width, GraphPanel.Height);
            //renderer.Render(graphImage);
            //GraphPanel.Image = graphImage;
        }