Exemplo n.º 1
0
        public void DrawSocialGraph(SocialNetwork graph)
        {
            Buttons    = new Button[graph.AllsnNode.Count];
            Buttons[0] = button1;
            Buttons[1] = button2;
            Buttons[2] = button3;
            Buttons[3] = button4;
            Buttons[4] = button5;
            Buttons[5] = button6;
            ButtonsID  = new int[40];

            int i = 0;
            int j = 0;

            foreach (var node in graph.AllsnNode)
            {
                Buttons[i].Text = node.UserName + "\n" + node.Job + "\n" + node.Node.Name;
                i++;
                foreach (var arc in node.Node.Arcs)
                {
                    ButtonsID[j] = arc.Parent.ID;
                    j++;
                    ButtonsID[j] = arc.Child.ID;
                    j++;
                }
            }
        }
Exemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Graph SocialGraph = new Graph();

            SocialNetwork s = new SocialNetwork(SocialGraph);

            Node Anode = SocialGraph.CreateRoot("A", 0);

            s.CreateSocialNetworkNode(Anode, "Olivia", "Doctor");
            Node Bnode = SocialGraph.CreateNode("B", 1);

            s.CreateSocialNetworkNode(Bnode, "Celine", "Engineer");
            Node Cnode = SocialGraph.CreateNode("C", 2);

            s.CreateSocialNetworkNode(Cnode, "Winston", "Politician");
            Node Dnode = SocialGraph.CreateNode("D", 3);

            s.CreateSocialNetworkNode(Dnode, "Chloe", "Architect");
            Node Enode = SocialGraph.CreateNode("E", 4);

            s.CreateSocialNetworkNode(Enode, "John", "Officer");
            Node Fnode = SocialGraph.CreateNode("F", 5);

            s.CreateSocialNetworkNode(Fnode, "Jack", "Professor");

            Anode.AddArc(Bnode, 5).AddArc(Enode, 12).AddArc(Fnode, 8);
            Bnode.AddArc(Fnode, 6).AddArc(Cnode, 10);
            Cnode.AddArc(Fnode, 16).AddArc(Dnode, 15);
            Dnode.AddArc(Fnode, 4).AddArc(Enode, 9);
            Enode.AddArc(Fnode, 7);
            DrawSocialGraph(s);

            dijkstra d2 = new dijkstra(Anode, Dnode, SocialGraph);

            label7.Text = d2.getListText();

            graph = new Graph();
            Node aNode = graph.CreateRoot("A");
            Node bNode = graph.CreateNode("B");
            Node cNode = graph.CreateNode("C");
            Node dNode = graph.CreateNode("D");
            Node eNode = graph.CreateNode("E");

            aNode.AddArc(cNode, 1).AddArc(bNode, 2);
            bNode.AddArc(cNode, 3);
            cNode.AddArc(dNode, 1).AddArc(eNode, 4);
            dNode.AddArc(eNode, 1);

            kuruskal = new Kruksal(graph);
            prim     = new Prim(aNode, graph);
        }