void FordFulkersonAlgo(Node nodeSource, Node nodeTerminal)
        {
            label_flow.Text = "Przepływ = 0";
            invalidateFlow();

            var flow = 0f;
            var path = Bfs(nodeSource, nodeTerminal);
            List<AlgoState> steps = new List<AlgoState>(); AlgoState cas = new AlgoState();

            while (path != null && path.Count > 0)
            {
                label_flow.Text = "Przepływ = " + flow;
                var minCapacity = float.MaxValue;
                foreach (var edge in path)
                {
                    if (((EdgeData)(edge.UserData)).currFlow < minCapacity)
                        minCapacity = ((EdgeData)(edge.UserData)).currFlow;
                }

                AugmentPath(path, minCapacity);
                flow += minCapacity;

                clearColors();
                reloadLabels();
                foreach (Edge e in path)
                {
                    foreach (Edge e2 in graph.Edges)
                    {
                        if (e2.Source == e.Source && e2.Target == e.Target) e2.Attr.Color = Color.Red;
                        //dirty code written without understanding Graph class - fixme!
                    }
                }
                label_flow.Text = "Przepływ = " + flow;
                redraw();
                DialogResult dr = MessageBox.Show("Tak=kontynuuj, Nie=wstecz o jeden krok", "pauza", MessageBoxButtons.YesNo);
                if (dr == DialogResult.Yes) {
                    cas.g = graph; cas.p = path; steps.Add(cas); 
                    path = Bfs(nodeSource, nodeTerminal);
                }
                else if (dr == DialogResult.No)
                {
                    if (steps.Count < 1)
                    {
                        MessageBox.Show("Nie można sie cofnąć!");
                    }
                    else { 
                        cas = steps[steps.Count - 1];
                        steps.RemoveAt(steps.Count - 1);
                        graph = cas.g; path = cas.p;
                        label_flow.Text = "Przepływ = " + flow;
                        continue;
                    }
                }
            }

            clearColors();
            reloadLabels();
            MessageBox.Show("Maksymalny przepływ wynosi: "+flow.ToString());
        }
        void FordFulkersonAlgo(Node nodeSource, Node nodeTerminal)
        {
            label_flow.Text = "Przepływ = 0";
            invalidateFlow();

            var flow = 0f;
            var path = Bfs(nodeSource, nodeTerminal);
            List <AlgoState> steps = new List <AlgoState>(); AlgoState cas = new AlgoState();

            while (path != null && path.Count > 0)
            {
                label_flow.Text = "Przepływ = " + flow;
                var minCapacity = float.MaxValue;
                foreach (var edge in path)
                {
                    if (((EdgeData)(edge.UserData)).currFlow < minCapacity)
                    {
                        minCapacity = ((EdgeData)(edge.UserData)).currFlow;
                    }
                }

                AugmentPath(path, minCapacity);
                flow += minCapacity;

                clearColors();
                reloadLabels();
                foreach (Edge e in path)
                {
                    foreach (Edge e2 in graph.Edges)
                    {
                        if (e2.Source == e.Source && e2.Target == e.Target)
                        {
                            e2.Attr.Color = Color.Red;
                        }
                        //dirty code written without understanding Graph class - fixme!
                    }
                }
                label_flow.Text = "Przepływ = " + flow;
                redraw();
                DialogResult dr = MessageBox.Show("Tak=kontynuuj, Nie=wstecz o jeden krok", "pauza", MessageBoxButtons.YesNo);
                if (dr == DialogResult.Yes)
                {
                    cas.g = graph; cas.p = path; steps.Add(cas);
                    path  = Bfs(nodeSource, nodeTerminal);
                }
                else if (dr == DialogResult.No)
                {
                    if (steps.Count < 1)
                    {
                        MessageBox.Show("Nie można sie cofnąć!");
                    }
                    else
                    {
                        cas = steps[steps.Count - 1];
                        steps.RemoveAt(steps.Count - 1);
                        graph           = cas.g; path = cas.p;
                        label_flow.Text = "Przepływ = " + flow;
                        continue;
                    }
                }
            }

            clearColors();
            reloadLabels();
            MessageBox.Show("Maksymalny przepływ wynosi: " + flow.ToString());
        }