Beispiel #1
0
        private Microsoft.Msagl.Drawing.Graph DFSHandler()
        {
            //////create a graph object
            string[]      testspek  = File.ReadAllLines(textBox1.Text);
            List <string> filenodes = BacaFile.getNodes(testspek);

            bool[,] adjMatrix = BacaFile.getAdjMatrix(testspek, filenodes);
            List <string> DFSpath = DFS.FindPathDFS(filenodes, adjMatrix, comboBox1.Text, comboBox2.Text);

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

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

                if (i == DFSpath.Count - 2)
                {
                    target.Attr.FillColor = Microsoft.Msagl.Drawing.Color.GreenYellow;
                }
            }
            return(graph);
        }
Beispiel #2
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);
        }