private void BFSButton(object sender, RoutedEventArgs e)
        {
            // clears the textbox
            TextboxnyaMathias.Text = String.Empty;

            ListMataKuliah LMataKuliah = new ListMataKuliah();

            try
            {
                LMataKuliah.ReadFile(TextBox.Text);
            } catch
            {
                TextboxnyaMathias.AppendText("Berkas tidak dapat ditemukan atau tidak valid");
            }

            //Call the BFS method
            List <List <int> > order = new List <List <int> >();

            order = LMataKuliah.topologicalSortBFS();
            //search for each time stamp that hasn't printed
            for (int i = 0; i < order.Count; i++)
            {
                // print number of semester
                TextboxnyaMathias.AppendText("Semester " + (i + 1) + ": ");
                int count = 0;
                foreach (int j in order[i])
                {
                    //print the elements
                    if (count > 0)
                    {
                        TextboxnyaMathias.AppendText(", ");
                    }
                    TextboxnyaMathias.AppendText(LMataKuliah.ListMatKul[j].NamaMataKuliah);
                    count++;
                }
                TextboxnyaMathias.AppendText("\n");
            }

            if (order.Count == 0)
            {
                TextboxnyaMathias.AppendText("Graf bukan merupakan graf asiklik");
            }

            LMataKuliah.DrawGraph(order, TampilGraf);

            // force garbage collection
            LMataKuliah = null;
            order       = null;
            GC.Collect();
        }
        private void DFSButton(object sender, RoutedEventArgs e)
        {
            // clears the textbox
            TextboxnyaMathias.Text = String.Empty;

            ListMataKuliah LMataKuliah = new ListMataKuliah();

            try
            {
                LMataKuliah.ReadFile(TextBox.Text);
            }
            catch
            {
                TextboxnyaMathias.AppendText("Berkas tidak dapat ditemukan atau tidak valid");
            }

            //Call the DFS method
            LMataKuliah.topologicalSortDFS();
            bool[] printed = new bool[LMataKuliah.ListMatKul.Count];
            //search for each time stamp that hasn't printed
            int count = 1;

            for (int i = LMataKuliah.ListMatKul.Count * 2; i >= 1; i--)
            {
                //search in each MatKul
                for (int j = 0; j < LMataKuliah.ListMatKul.Count; j++)
                {
                    if (LMataKuliah.ListMatKul[j].outTimeStamp == i && !printed[j])
                    {
                        //print the elements
                        TextboxnyaMathias.AppendText("Semester " + count + ": ");
                        TextboxnyaMathias.AppendText(LMataKuliah.ListMatKul[j].NamaMataKuliah + " (");
                        TextboxnyaMathias.AppendText(LMataKuliah.ListMatKul[j].inTimeStamp + "/");
                        TextboxnyaMathias.AppendText(LMataKuliah.ListMatKul[j].outTimeStamp + ")\n");
                        count++;
                        break;
                    }
                }
            }

            TampilGraf.Source = convert(LMataKuliah.DrawGraph());

            // force garbage collection
            LMataKuliah = null;
            printed     = null;
            GC.Collect();
        }