private void onMaxFlow(object sender, EventArgs e) { if (CurrentGraphPanel == null) { return; } //Make sure one vertex is selected List <ISelectable> selection = CurrentGraphPanel.GetSelection(); GUIVertex source, sink; if (selection.Count != 2) { Output.WriteLine("Please select both the source and the sink, in that order"); return; } else if (selection[0] as GUIVertex == null || selection[1] as GUIVertex == null) { Output.WriteLine("Please select both the source and the sink, in that order"); return; } else { source = selection[0] as GUIVertex; sink = selection[1] as GUIVertex; } List <GUIVertex> verts = CurrentGraphPanel.Vertices; FlowNetwork fn = CurrentGraphPanel.Graph as FlowNetwork; if (fn != null) { float max = GraphAlgorithms.MaximumFlow(fn, fn.GetVertices().IndexOf(source.Vertex), fn.GetVertices().IndexOf(sink.Vertex)); Output.WriteLine("[Max Flow Output]"); Output.WriteLine("Max flow is " + max); Output.WriteLine("[End Max Flow Output]"); } }