private void buttonInitGraph_Click(object sender, EventArgs e) { try { ParseGraph(textBoxInitGraph.Text); string dot = ConvertGraphToDot(MainGraph); textBoxInitGraph.Text = dot; VisualizeGraph(dot); PlanarityTester = new PlanarityTester(MainGraph); WriteStatus("Graph is initialized! Click \"Apply Simplifying Step\" to apply preprocessing and simple tests."); } catch (Exception ex) { WriteStatus("Error visualizing graph: " + ex.Message); } }
private async void ApplySimplifyingStepsByShowingProcesses() { try { buttonSimplifyStep.Enabled = false; buttonApplyPlanarityStep.Enabled = false; buttonInitGraph.Enabled = false; foreach (string preprocessMessage in PlanarityTester.ApplySimplifyingStep()) { string dot = ConvertGraphToDot(PlanarityTester.GraphParts); VisualizeGraph(dot); WriteStatus(preprocessMessage); await Task.Delay(WaitBetweenSimplifyingSteps); } bool canSimplifyAgain = PlanarityTester.SimplifyResult == SimplifyResult.CanSimplifyAgain; if (PlanarityTester.PlanarityResult == PlanarityResult.NonPlanar) { WriteStatus("Graph is NON-PLANAR! This is determined in the simplifying step."); } else if (PlanarityTester.PlanarityResult == PlanarityResult.Planar) { WriteStatus("Graph is PLANAR! This is determined in the simplifying step."); } else { WriteStatus(canSimplifyAgain ? "Graph is simplified! It may be further simplified, click \"Apply Simplifying Step\" again." : "Graph is simplified! It cannot be simplified anymore. Click \"Apply Planarity Test Step\" button."); } buttonSimplifyStep.Enabled = true; buttonApplyPlanarityStep.Enabled = true; buttonInitGraph.Enabled = true; } catch (Exception ex) { WriteStatus("Error simplifying graph: " + ex.Message); } }
private async void ApplyTestingStepByShowingProcess() { try { buttonSimplifyStep.Enabled = false; buttonApplyPlanarityStep.Enabled = false; buttonInitGraph.Enabled = false; foreach (string preprocessMessage in PlanarityTester.ApplyPlanarityTestStep()) { string dot = ConvertGraphToDot(PlanarityTester.SubGraph); VisualizeGraph(dot); WriteStatus(preprocessMessage); await Task.Delay(WaitBetweenTestingSteps); } VisualizeGraph(ConvertGraphToDot(PlanarityTester.GraphParts)); if (PlanarityTester.PlanarityResult == PlanarityResult.Planar) { WriteStatus("Graph is PLANAR! This is determined in the planarity testing step."); } else if (PlanarityTester.PlanarityResult == PlanarityResult.NonPlanar) { WriteStatus("Graph is NON-PLANAR! This is determined in the planarity testing step."); } else if (PlanarityTester.PlanarityResult == PlanarityResult.Undetermined) { WriteStatus("Graph is UNDETERMINED! This shouldn't have happened :("); } buttonSimplifyStep.Enabled = true; buttonApplyPlanarityStep.Enabled = true; buttonInitGraph.Enabled = true; } catch (Exception ex) { WriteStatus("Error testing planarity: " + ex.Message); } }