private void button2_Click(object sender, EventArgs e) { //upload button if (!(textBox1.Text.Equals(""))) { //for (int i = 0; i < textData.getTotalPeople(); i++) graph.RemoveNode(graph.FindNode(textData.getPerson(i))); //g.Clear(); textData = new TextHandler(); prevAccount = ""; prevExplore = ""; comboBox1.Items.Clear(); comboBox2.Items.Clear(); textData.Load(textBox1.Text); graph = new Microsoft.Msagl.Drawing.Graph("graph"); g = new GraphKita(textData); for (int i = 0; i < textData.getTotalConnection(); i++) { g.NewEdge(textData.getFriendConnection(i)[0], textData.getFriendConnection(i)[1]); var edge = graph.AddEdge(textData.getFriendConnection(i)[0], textData.getFriendConnection(i)[1]); edge.Attr.ArrowheadAtSource = Microsoft.Msagl.Drawing.ArrowStyle.None; edge.Attr.ArrowheadAtTarget = Microsoft.Msagl.Drawing.ArrowStyle.None; } for (int i = 0; i < textData.getTotalPeople(); i++) { comboBox1.Items.Add(textData.getPerson(i)); comboBox2.Items.Add(textData.getPerson(i)); } if ((textData.getTotalPeople() == 1)) { comboBox1.SelectedItem = (textData.getPerson(0)); comboBox2.SelectedItem = (textData.getPerson(0)); button3.Enabled = true; } else if ((textData.getTotalPeople() > 1)) { comboBox1.SelectedItem = (textData.getPerson(0)); comboBox2.SelectedItem = (textData.getPerson(1)); comboBox1.Items.Remove(comboBox2.SelectedItem.ToString()); comboBox2.Items.Remove(comboBox1.SelectedItem.ToString()); comboBox1.Enabled = true; comboBox2.Enabled = true; button3.Enabled = true; } printGraph(); instantSearch(); } else { Console.WriteLine("Path file tidak valid"); } }
private List <List <string> > pointingTo; //list of list of string, yang tiap index nya adalah node-node yg ditunjuk oleh node bersangkutan //Misal //nodes = ["A","B"] //pointingTo = [ ["A"], ["B"], ["C"] ] //Berarti, node A menunjuk ke node B dan C, dst //Maaf kalau keliru istilah. idgaf about istilah public GraphKita(TextHandler handler) { //ctor with size nodes = new List <string>(); pointingTo = new List <List <string> >(); totalnode = handler.getTotalPeople(); for (int i = 0; i < handler.getTotalPeople(); i++) { pointingTo.Add(new List <string>()); pointingTo[i].Add(handler.getPerson(i)); nodes.Add(handler.getPerson(i)); //Console.WriteLine(pointingTo[i][0]); } //Console.WriteLine(pointingTo.Count); }