package aufgabe1.algorithms;

import aufgabe1.Vertex;
import junit.framework.TestCase;
import org.jgrapht.graph.DefaultWeightedEdge;
import org.jgrapht.graph.DirectedWeightedPseudograph;

public class FordFulkersonTest extends TestCase {
    public void testRun() throws Exception {
        DirectedWeightedPseudograph<Vertex, DefaultWeightedEdge> graph = new DirectedWeightedPseudograph(DefaultWeightedEdge.class);

        Vertex a = new Vertex("A");
        Vertex b = new Vertex("B");
        Vertex c = new Vertex("C");
        Vertex d = new Vertex("D");
        Vertex s = new Vertex("S");
        Vertex t = new Vertex("T");

        graph.addVertex(a);
        graph.addVertex(b);
        graph.addVertex(c);
        graph.addVertex(d);
        graph.addVertex(s);
        graph.addVertex(t);

        graph.setEdgeWeight(graph.addEdge(s, a), 9);
        graph.setEdgeWeight(graph.addEdge(s, b), 9);
        graph.setEdgeWeight(graph.addEdge(a, c), 8);
        graph.setEdgeWeight(graph.addEdge(a, b), 10);
        graph.setEdgeWeight(graph.addEdge(b, c), 1);
        graph.setEdgeWeight(graph.addEdge(b, d), 3);
        graph.setEdgeWeight(graph.addEdge(c, t), 10);
        graph.setEdgeWeight(graph.addEdge(d, c), 8);
        graph.setEdgeWeight(graph.addEdge(d, t), 7);

        FordFulkerson fordFulkerson = new FordFulkerson(graph);
        fordFulkerson.run(s, t);


    }
}
@@ -58,32 +58,86 @@
 ort 
-junit.framework.TestCase
+aufgabe1.io.GraphIO;%0Aimport junit.framework.TestCase;%0Aimport org.jgrapht.Graph
 ;%0Aim
@@ -233,16 +233,107 @@
 dograph;
+%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0Aimport java.io.File;%0Aimport java.net.URL;
 %0A%0Apublic
@@ -375,16 +375,27 @@
 stCase %7B
+%0A%0A    @Test
 %0A    pub
@@ -1530,16 +1530,1694 @@
 s, t);%0A%0A
+        Assert.assertEquals(12, fordFulkerson.getMaxFlow());%0A    %7D%0A%0A    @Test%0A    public void testRun2() throws Exception %7B%0A        DirectedWeightedPseudograph%3CVertex, DefaultWeightedEdge%3E graph = new DirectedWeightedPseudograph(DefaultWeightedEdge.class);%0A%0A        Vertex s = new Vertex(%22s%22);%0A        graph.addVertex(s);%0A        Vertex u = new Vertex(%22u%22);%0A        graph.addVertex(u);%0A        Vertex v = new Vertex(%22v%22);%0A        graph.addVertex(v);%0A        Vertex t = new Vertex(%22t%22);%0A        graph.addVertex(t);%0A%0A%0A        graph.setEdgeWeight(graph.addEdge(s, u), 10);%0A        graph.setEdgeWeight(graph.addEdge(s, u), 10);%0A        graph.setEdgeWeight(graph.addEdge(s, v), 10);%0A        graph.setEdgeWeight(graph.addEdge(u, t), 10);%0A        graph.setEdgeWeight(graph.addEdge(u, v), 30);%0A        graph.setEdgeWeight(graph.addEdge(v, t), 20);%0A%0A%0A        FordFulkerson fordFulkerson = new FordFulkerson(graph);%0A        fordFulkerson.run(s, t);%0A%0A        Assert.assertEquals(30, fordFulkerson.getMaxFlow());%0A    %7D%0A%0A    @Test%0A    public void testRun3() throws Exception %7B%0A        GraphIO graphIO = new GraphIO();%0A        URL url = getClass().getResource(%22/graph4.gka.txt%22);%0A        File file = new File(url.toURI());%0A%0A        Graph%3CVertex, DefaultWeightedEdge%3E graph = graphIO.readGraphFromFile(file);%0A%0A        Vertex q = graph.vertexSet().stream().filter(vertex -%3E vertex.getName().equals(%22q%22)).findFirst().get();%0A        Vertex s = graph.vertexSet().stream().filter(vertex -%3E vertex.getName().equals(%22s%22)).findFirst().get();%0A%0A        FordFulkerson fordFulkerson = new FordFulkerson(graph);%0A        fordFulkerson.run(q, s);%0A%0A        Assert.assertEquals(26, fordFulkerson.getMaxFlow());
 %0A    %7D%0A%7D

Add test