private void saveFileMenuItem_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.SaveFileDialog fileDialog = new Microsoft.Win32.SaveFileDialog();
            fileDialog.OverwritePrompt = true;
            fileDialog.ShowDialog();

            try
            {
                using (StreamWriter writer = new StreamWriter(File.Create(fileDialog.FileName)))
                {
                    writer.WriteLine("#nodes section");
                    writer.WriteLine(persons.Count);

                    foreach (Person person in persons)
                    {
                        writer.WriteLine("{" + person.Name + "}");
                    }

                    writer.WriteLine();
                    writer.WriteLine("#edges section");

                    int relationsCnt = 0;
                    foreach (Person person in persons)
                    {
                        relationsCnt  += person.Neighbors.Count;
                        person.Flagged = false;
                    }
                    relationsCnt = relationsCnt / 2;

                    writer.WriteLine(relationsCnt);

                    Stack <Person> stack = new Stack <Person>();
                    foreach (List <Person> component in Plg.findConnectedComponents(persons))
                    {
                        stack.Push(component[0]);

                        while (stack.Count > 0)
                        {
                            Person currentPerson = stack.Pop();
                            currentPerson.Flagged = true;

                            foreach (Person neighbor in currentPerson.Neighbors)
                            {
                                if (!neighbor.Flagged)
                                {
                                    writer.WriteLine(String.Format("{0} {1}", currentPerson.ID + 1, neighbor.ID + 1));
                                    stack.Push(neighbor);
                                }
                            }
                        }
                    }
                }
            }

            //File dialog closed without selecting anything
            catch (ArgumentException)
            { }
        }
        void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            Plg plg;

            lock (persons)
            {
                plg = new Plg(persons);
            }

            Person[] output;
            string   outString;

            if (!plg.TestIntervalGraph(out output))
            {
                if (output.Length == 3)
                {
                    outString = "AT gefunden: \r\n";
                }
                else
                {
                    outString = "Sehnenloser Kreis gefunden:\r\n";
                }

                foreach (Person p in output)
                {
                    outString += p.Name;
                    outString += "\r\n";
                }

                if (output.Length == 3)
                {
                    var result = plg.FindATPaths(output);
                    foreach (var list in result)
                    {
                        outString += "Pfad:\r\nStart:\r\n";

                        foreach (Person p in list)
                        {
                            outString += p.Name + "\r\n";
                        }

                        outString += ":Ende\r\n";
                    }
                }
            }

            else
            {
                outString = "Intervalldarstellung erzeugt:\r\n";
                foreach (Person p in persons)
                {
                    outString += String.Format("{0}: Von {1} bis {2}\r\n", p.Name, p.Birth, p.Death);
                }
            }

            e.Result = outString;
        }