// Path: src/main/java/com/clematis/core/episode/Episode.java
// @XmlRootElement
// public class Episode {
// 	// private EpisodeSource source;
// 	private TraceObject source;
// 	private EpisodeTrace trace;
// 	private String dom;
// 	private boolean isBookmarked;
// 
// 	public Episode() {
// 
// 	}
// 
// 	/*
// 	 * public Episode(EpisodeSource source) { trace = new EpisodeTrace(); }
// 	 */
// 	public Episode(TraceObject source) {
// 		trace = new EpisodeTrace();
// 		this.source = source;
// 	}
// 
// 	public void addToTrace(TraceObject to) {
// 		trace.addToTrace(to);
// 	}
// 
// 	/*
// 	 * public EpisodeSource getSource() { return source; } public void setSource(EpisodeSource
// 	 * source) { this.source = source; }
// 	 */public EpisodeTrace getTrace() {
// 		return trace;
// 	}
// 
// 	public void setTrace(EpisodeTrace trace) {
// 		this.trace = trace;
// 	}
// 
// 	public String getDom() {
// 		return dom;
// 	}
// 
// 	public void setDom(String dom) {
// 		this.dom = dom;
// 	}
// 
// 	public TraceObject getSource() {
// 		return source;
// 	}
// 
// 	public void setSource(TraceObject source) {
// 		this.source = source;
// 	}
// 	
// 	public boolean getIsBookmarked() {
// 		return isBookmarked;
// 	}
// 
// 	public void setIsBookmarked(boolean isBookmarked) {
// 		this.isBookmarked = isBookmarked;
// 	}
// }
// 
// Path: src/main/java/com/clematis/core/trace/TraceObject.java
// @JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class")
// public class TraceObject implements Comparable<TraceObject> {
// 	private int id;
// 	private int counter;
// 	private String messageType;
// 	private long timeStamp;
// 	private boolean isEpisodeSource;
// //	private boolean isBookmarked;
// 	
// 	public TraceObject() {
// 		isEpisodeSource = false;
// //		isBookmarked = false;
// 	}
// 	
// 	public int getCounter() {
// 		return counter;
// 	}
// 	public void setCounter(int counter) {
// 		this.counter = counter;
// 	}
// 	public int getId() {
// 		return id;
// 	}
// 	public void setId(int id) {
// 		this.id = id;
// 	}
// 	public String getMessageType() {
// 		return messageType;
// 	}
// 	public void setMessageType(String messageType) {
// 		this.messageType = messageType;
// 	}
// 	public long getTimeStamp() {
// 		return timeStamp;
// 	}
// 	public void setTimeStamp(long timeStamp) {
// 		this.timeStamp = timeStamp;
// 	}
// 	public int compareTo(TraceObject o) {
// 		if (counter < o.getCounter())
// 			return -1;
// 		else if (counter > o.getCounter())
// 			return 1;
// 		return 0;
// 	}
// 	
// 	public boolean isEpisodeSource() {
// 		return isEpisodeSource;
// 	}
// 	
// 	public void setEpisodeSource(boolean isEpisodeSource) {
// 		this.isEpisodeSource = isEpisodeSource;
// 	}
// /*
// 	public boolean getIsBookmarked() {
// 		return isBookmarked;
// 	}
// 
// 	public void setIsBookmarked(boolean isBookmarked) {
// 		this.isBookmarked = isBookmarked;
// 	}
// 	*/
// }


import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Date;
import org.jgrapht.ext.DOTExporter;
import org.jgrapht.ext.StringEdgeNameProvider;
import org.jgrapht.ext.StringNameProvider;
import org.jgrapht.graph.DefaultEdge;
import org.jgrapht.graph.DirectedMultigraph;
import com.crawljax.util.Helper;
import com.clematis.core.episode.Episode;
import com.clematis.core.trace.TraceObject;
	{
		String newVertex = "E" + e.getSource().getCounter();

		try {
			// Add the vertex
			dirGraph.addVertex(newVertex);
		} catch (Exception ee) {
			System.out.println("addVertex: Error adding vertex to dir. graph.");
			ee.printStackTrace();
		}
		return newVertex;
	}

	public void addEdge(Episode v1, Episode v2, TraceObject b1)
	{
		if (v1.equals(v2)) {
			// Loops are not allowed
			System.out.println("No loops allowed!");
			return;
		} 
		String label = null;
		if (b1.getClass().toString().contains("Timeout")) {
			label = "TID: " + b1.getId();
		} else {
			label = "XHR ID: " + b1.getId();
		}
		try {
			// Add the edge
			dirGraph.addEdge("E"+v1.getSource().getCounter(), 
					"E"+v2.getSource().getCounter(), 
// Path: src/main/java/com/clematis/core/episode/Episode.java
// @XmlRootElement
// public class Episode {
// 	// private EpisodeSource source;
// 	private TraceObject source;
// 	private EpisodeTrace trace;
// 	private String dom;
// 	private boolean isBookmarked;
// 
// 	public Episode() {
// 
// 	}
// 
// 	/*
// 	 * public Episode(EpisodeSource source) { trace = new EpisodeTrace(); }
// 	 */
// 	public Episode(TraceObject source) {
// 		trace = new EpisodeTrace();
// 		this.source = source;
// 	}
// 
// 	public void addToTrace(TraceObject to) {
// 		trace.addToTrace(to);
// 	}
// 
// 	/*
// 	 * public EpisodeSource getSource() { return source; } public void setSource(EpisodeSource
// 	 * source) { this.source = source; }
// 	 */public EpisodeTrace getTrace() {
// 		return trace;
// 	}
// 
// 	public void setTrace(EpisodeTrace trace) {
// 		this.trace = trace;
// 	}
// 
// 	public String getDom() {
// 		return dom;
// 	}
// 
// 	public void setDom(String dom) {
// 		this.dom = dom;
// 	}
// 
// 	public TraceObject getSource() {
// 		return source;
// 	}
// 
// 	public void setSource(TraceObject source) {
// 		this.source = source;
// 	}
// 	
// 	public boolean getIsBookmarked() {
// 		return isBookmarked;
// 	}
// 
// 	public void setIsBookmarked(boolean isBookmarked) {
// 		this.isBookmarked = isBookmarked;
// 	}
// }
// 
// Path: src/main/java/com/clematis/core/trace/TraceObject.java
// @JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class")
// public class TraceObject implements Comparable<TraceObject> {
// 	private int id;
// 	private int counter;
// 	private String messageType;
// 	private long timeStamp;
// 	private boolean isEpisodeSource;
// //	private boolean isBookmarked;
// 	
// 	public TraceObject() {
// 		isEpisodeSource = false;
// //		isBookmarked = false;
// 	}
// 	
// 	public int getCounter() {
// 		return counter;
// 	}
// 	public void setCounter(int counter) {
// 		this.counter = counter;
// 	}
// 	public int getId() {
// 		return id;
// 	}
// 	public void setId(int id) {
// 		this.id = id;
// 	}
// 	public String getMessageType() {
// 		return messageType;
// 	}
// 	public void setMessageType(String messageType) {
// 		this.messageType = messageType;
// 	}
// 	public long getTimeStamp() {
// 		return timeStamp;
// 	}
// 	public void setTimeStamp(long timeStamp) {
// 		this.timeStamp = timeStamp;
// 	}
// 	public int compareTo(TraceObject o) {
// 		if (counter < o.getCounter())
// 			return -1;
// 		else if (counter > o.getCounter())
// 			return 1;
// 		return 0;
// 	}
// 	
// 	public boolean isEpisodeSource() {
// 		return isEpisodeSource;
// 	}
// 	
// 	public void setEpisodeSource(boolean isEpisodeSource) {
// 		this.isEpisodeSource = isEpisodeSource;
// 	}
// /*
// 	public boolean getIsBookmarked() {
// 		return isBookmarked;
// 	}
// 
// 	public void setIsBookmarked(boolean isBookmarked) {
// 		this.isBookmarked = isBookmarked;
// 	}
// 	*/
// }


// Path: src/main/java/com/clematis/visual/EpisodeGraph.java
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Date;
import org.jgrapht.ext.DOTExporter;
import org.jgrapht.ext.StringEdgeNameProvider;
import org.jgrapht.ext.StringNameProvider;
import org.jgrapht.graph.DefaultEdge;
import org.jgrapht.graph.DirectedMultigraph;
import com.crawljax.util.Helper;
import com.clematis.core.episode.Episode;
import com.clematis.core.trace.TraceObject;

	{
		String newVertex = "E" + e.getSource().getCounter();

		try {
			// Add the vertex
			dirGraph.addVertex(newVertex);
		} catch (Exception ee) {
			System.out.println("addVertex: Error adding vertex to dir. graph.");
			ee.printStackTrace();
		}
		return newVertex;
	}

	public void addEdge(Episode v1, Episode v2, TraceObject b1)
	{
		if (v1.equals(v2)) {
			// Loops are not allowed
			System.out.println("No loops allowed!");
			return;
		} 
		String label = null;
		if (b1.getClass().toString().contains("Timeout")) {
			label = "TID: " + b1.getId();
		} else {
			label = "XHR ID: " + b1.getId();
		}
		try {
			// Add the edge
			dirGraph.addEdge("E"+v1.getSource().getCounter(), 
					"E"+v2.getSource().getCounter(), 
					new RelationshipEdge<String>("E"+v1.getSource().getCounter(), "E"+v2.getSource().getCounter(), b1));