Beispiel #1
0
        private Microsoft.Msagl.Drawing.Graph getPlainGraph(List <string> DFSpath)
        {
            string[]      testspek  = File.ReadAllLines(textBox1.Text);
            List <string> filenodes = BacaFile.getNodes(testspek);

            bool[,] adjMatrix = BacaFile.getAdjMatrix(testspek, filenodes);

            Microsoft.Msagl.Drawing.Graph graph2 = new Microsoft.Msagl.Drawing.Graph("graph");
            int totalNode = filenodes.Count;
            int totalAdj = adjMatrix.Length;
            int idx = 0;
            int i; int j;

            while (idx < totalAdj)
            {
                i = idx / totalNode;
                j = idx % totalNode;

                if (adjMatrix[i, j])
                {
                    if (!isValidDFSPath(filenodes[i], filenodes[j], DFSpath))
                    {
                        graph2.AddEdge(filenodes[i], filenodes[j]).Attr.ArrowheadAtTarget = Microsoft.Msagl.Drawing.ArrowStyle.None;
                    }
                    adjMatrix[j, i] = false;
                }
                idx++;
            }
            return(graph2);
        }
Beispiel #2
0
        private Microsoft.Msagl.Drawing.Graph BFSHandler()
        {
            string[]      testspek  = File.ReadAllLines(textBox1.Text);
            List <string> filenodes = BacaFile.getNodes(testspek);

            bool[,] adjMatrix = BacaFile.getAdjMatrix(testspek, filenodes);
            List <string> BFSpath = BFS.FindPathBFS(filenodes, adjMatrix, comboBox1.Text, comboBox2.Text);

            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
            graph = getPlainGraph(BFSpath);
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            for (int i = 0; i < BFSpath.Count - 1; i++)
            {
                Microsoft.Msagl.Drawing.Node source = graph.FindNode(BFSpath[i]);
                Microsoft.Msagl.Drawing.Node target = graph.FindNode(BFSpath[i + 1]);
                source.Attr.FillColor = Microsoft.Msagl.Drawing.Color.GreenYellow;
                var edge = graph.AddEdge(BFSpath[i], BFSpath[i + 1]);
                edge.Attr.Color             = Microsoft.Msagl.Drawing.Color.GreenYellow;
                edge.Attr.ArrowheadAtTarget = Microsoft.Msagl.Drawing.ArrowStyle.None;

                if (i == BFSpath.Count - 2)
                {
                    target.Attr.FillColor = Microsoft.Msagl.Drawing.Color.GreenYellow;
                }
            }
            return(graph);
        }
Beispiel #3
0
        private void handleMutualFriends(object sender, EventArgs e, Microsoft.Msagl.Drawing.Graph graph)
        {
            string[]      testspek  = File.ReadAllLines(textBox1.Text);
            List <string> filenodes = BacaFile.getNodes(testspek);

            bool[,] adjMatrix = BacaFile.getAdjMatrix(testspek, filenodes);

            Dictionary <string, List <string> > mutuals = DFS.MutualFriendsDFS(filenodes, adjMatrix, comboBox1.Text);

            createMutualVisual(sender, e, mutuals, graph);
        }
Beispiel #4
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string[]      testspek  = File.ReadAllLines(textBox1.Text);
            List <string> filenodes = BacaFile.getNodes(testspek);

            foreach (string node in filenodes)
            {
                if (comboBox1.Items.Contains(node) || comboBox2.Text == node)
                {
                    // do nothing
                }
                else
                {
                    comboBox1.Items.Add(node);
                }
            }
        }