// Path: src/main/java/de/jfschaefer/layeredgraphlayout/Edge.java
// public class Edge<V, E> {
//     protected E originalEdge;
//     protected Node<V, E> from, to;
//     protected boolean flipped = false;
//     protected boolean locked = false;
// 
//     public Edge(E original, Node<V, E> from, Node<V, E> to) {
//         originalEdge = original;
//         this.from = from;
//         this.to = to;
//         from.addOutgoingEdge(this);
//         to.addIngoingEdge(this);
//     }
// 
//     public E getOriginalEdge() {
//         return originalEdge;
//     }
// 
//     public Node<V, E> getFrom() {
//         return flipped ? to : from;
//     }
// 
//     public Node<V, E> getTo() {
//         return flipped ? from : to;
//     }
// 
//     public Node<V, E> getRealFrom() {
//         return from;
//     }
// 
//     public Node<V, E> getRealTo() {
//         return to;
//     }
// 
//     public boolean isFlipped() {
//         return flipped;
//     }
// 
//     public void flip() {
//         assert !locked;
//         getFrom().reverseOutgoingEdge(this);
//         getTo().reverseIngoingEdge(this);
//         flipped = !flipped;
//     }
// 
//     public void lock() {
//         locked = true;
//     }
// 
//     public boolean isLocked() {
//         return locked;
//     }
// }


import de.jfschaefer.layeredgraphlayout.Edge;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
package de.jfschaefer.layeredgraphlayout.gengraph;



/**
 * Created by jfschaefer on 8/14/15.
 */

public class GenGraphTest extends TestCase {
    public GenGraphTest(String testName) {
        super(testName);
    }

    public static Test suite() {
        return new TestSuite(GenGraphTest.class);
    }

    public void testRemoveCyclesGreedy() {
        GenGraph<String, String> graph = new GenGraph<String, String>();

        String[] nodes = {"n1", "n2", "n3"};
        String[] edges = {"e1", "e2", "e3"};
        graph.addNode(nodes[0], 10d, 10d);
        graph.addNode(nodes[1], 10d, 10d);
        graph.addNode(nodes[2], 10d, 10d);
        graph.addEdge(edges[0], nodes[0], nodes[1]);
        graph.addEdge(edges[1], nodes[1], nodes[2]);
        graph.addEdge(edges[2], nodes[2], nodes[0]);
        graph.removeCyclesGreedy();
        int counter = 0;
        assertEquals(graph.getEdges().size(), 3);
// Path: src/main/java/de/jfschaefer/layeredgraphlayout/Edge.java
// public class Edge<V, E> {
//     protected E originalEdge;
//     protected Node<V, E> from, to;
//     protected boolean flipped = false;
//     protected boolean locked = false;
// 
//     public Edge(E original, Node<V, E> from, Node<V, E> to) {
//         originalEdge = original;
//         this.from = from;
//         this.to = to;
//         from.addOutgoingEdge(this);
//         to.addIngoingEdge(this);
//     }
// 
//     public E getOriginalEdge() {
//         return originalEdge;
//     }
// 
//     public Node<V, E> getFrom() {
//         return flipped ? to : from;
//     }
// 
//     public Node<V, E> getTo() {
//         return flipped ? from : to;
//     }
// 
//     public Node<V, E> getRealFrom() {
//         return from;
//     }
// 
//     public Node<V, E> getRealTo() {
//         return to;
//     }
// 
//     public boolean isFlipped() {
//         return flipped;
//     }
// 
//     public void flip() {
//         assert !locked;
//         getFrom().reverseOutgoingEdge(this);
//         getTo().reverseIngoingEdge(this);
//         flipped = !flipped;
//     }
// 
//     public void lock() {
//         locked = true;
//     }
// 
//     public boolean isLocked() {
//         return locked;
//     }
// }


// Path: src/test/java/de/jfschaefer/layeredgraphlayout/gengraph/GenGraphTest.java
import de.jfschaefer.layeredgraphlayout.Edge;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

package de.jfschaefer.layeredgraphlayout.gengraph;



/**
 * Created by jfschaefer on 8/14/15.
 */

public class GenGraphTest extends TestCase {
    public GenGraphTest(String testName) {
        super(testName);
    }

    public static Test suite() {
        return new TestSuite(GenGraphTest.class);
    }

    public void testRemoveCyclesGreedy() {
        GenGraph<String, String> graph = new GenGraph<String, String>();

        String[] nodes = {"n1", "n2", "n3"};
        String[] edges = {"e1", "e2", "e3"};
        graph.addNode(nodes[0], 10d, 10d);
        graph.addNode(nodes[1], 10d, 10d);
        graph.addNode(nodes[2], 10d, 10d);
        graph.addEdge(edges[0], nodes[0], nodes[1]);
        graph.addEdge(edges[1], nodes[1], nodes[2]);
        graph.addEdge(edges[2], nodes[2], nodes[0]);
        graph.removeCyclesGreedy();
        int counter = 0;
        assertEquals(graph.getEdges().size(), 3);
        for (Edge edge : graph.getEdges()) {