/**
 * 
 */
package com.codemelon.graph.search;

import static org.junit.Assert.*;

import java.util.HashMap;

import org.junit.After;
import org.junit.Test;

import com.codemelon.graph.OldDiGraph;
import com.codemelon.graph.vertex.CompleteVertex;

/**
 * @author Marshall Farrier
 * @version Nov 27, 2012
 *
 */
public class TopologicalSortTest {
	private OldDiGraph graph;
	
	@After
	public void tearDown() {
		graph = null;
	}

	/**
	 * Test method for {@link com.codemelon.graph.util.search.depthfirst.TopologicalSort#sort()}.
	 */
	@Test
	public void testSmallCLRSGraph() {
		HashMap<String, CompleteVertex> vertices = setUpSmallCLRSGraph();
		TopologicalSort topSort = new TopologicalSort(graph);
		assertTrue("Proper precedences", topSort.showsAsInOrder(vertices.get("undershorts"), 
				vertices.get("pants")));
		assertTrue("Proper precedences", topSort.showsAsInOrder(vertices.get("socks"), 
				vertices.get("shoes")));
		assertTrue("Proper precedences", topSort.showsAsInOrder(vertices.get("pants"), 
				vertices.get("belt")));
		assertTrue("Proper precedences", topSort.showsAsInOrder(vertices.get("undershorts"), 
				vertices.get("shoes")));
		assertTrue("Proper precedences", topSort.showsAsInOrder(vertices.get("pants"), 
				vertices.get("shoes")));
		assertTrue("Proper precedences", topSort.showsAsInOrder(vertices.get("shirt"), 
				vertices.get("belt")));
		assertTrue("Proper precedences", topSort.showsAsInOrder(vertices.get("shirt"), 
				vertices.get("tie")));
		assertTrue("Proper precedences", topSort.showsAsInOrder(vertices.get("tie"), 
				vertices.get("jacket")));
	}
	/**
	 * Graph from CLRS, p. 613
	 */
	private HashMap<String, CompleteVertex> setUpSmallCLRSGraph() {
		HashMap<String, CompleteVertex> vertices = new HashMap<String, CompleteVertex>();
		vertices.put("undershorts", new CompleteVertex());
		vertices.put("pants", new CompleteVertex());
		vertices.put("belt", new CompleteVertex());
		vertices.put("shirt", new CompleteVertex());
		vertices.put("tie", new CompleteVertex());
		vertices.put("jacket", new CompleteVertex());
		vertices.put("socks", new CompleteVertex());
		vertices.put("shoes", new CompleteVertex());
		vertices.put("watch", new CompleteVertex());
		graph = new OldDiGraph(vertices.values());
		graph.addEdge(vertices.get("undershorts"), vertices.get("pants"));
		graph.addEdge(vertices.get("undershorts"), vertices.get("shoes"));
		graph.addEdge(vertices.get("pants"), vertices.get("belt"));
		graph.addEdge(vertices.get("pants"), vertices.get("shoes"));
		graph.addEdge(vertices.get("socks"), vertices.get("shoes"));
		graph.addEdge(vertices.get("shirt"), vertices.get("belt"));
		graph.addEdge(vertices.get("shirt"), vertices.get("tie"));
		graph.addEdge(vertices.get("belt"), vertices.get("jacket"));
		graph.addEdge(vertices.get("tie"), vertices.get("jacket"));
		return vertices;
	}
}

@@ -1,16 +1,4 @@
-/**%0A * %0A */%0A
 pack
@@ -167,19 +167,22 @@
 n.graph.
-Old
+graph.
 DiGraph;
@@ -216,24 +216,25 @@
 .vertex.
-Complete
+types.Dfs
 Vertex;%0A
@@ -342,26 +342,34 @@
 private 
-Old
 DiGraph
+%3CDfsVertex%3E
  graph;%0A
@@ -586,32 +586,27 @@
 Map%3CString, 
-Complete
+Dfs
 Vertex%3E vert
@@ -1648,32 +1648,27 @@
 Map%3CString, 
-Complete
+Dfs
 Vertex%3E setU
@@ -1701,32 +1701,27 @@
 Map%3CString, 
-Complete
+Dfs
 Vertex%3E vert
@@ -1747,24 +1747,19 @@
 String, 
-Complete
+Dfs
 Vertex%3E(
@@ -1791,32 +1791,27 @@
 horts%22, new 
-Complete
+Dfs
 Vertex());%0A%09
@@ -1833,32 +1833,27 @@
 pants%22, new 
-Complete
+Dfs
 Vertex());%0A%09
@@ -1874,32 +1874,27 @@
 %22belt%22, new 
-Complete
+Dfs
 Vertex());%0A%09
@@ -1916,32 +1916,27 @@
 shirt%22, new 
-Complete
+Dfs
 Vertex());%0A%09
@@ -1956,32 +1956,27 @@
 (%22tie%22, new 
-Complete
+Dfs
 Vertex());%0A%09
@@ -1999,32 +1999,27 @@
 acket%22, new 
-Complete
+Dfs
 Vertex());%0A%09
@@ -2041,32 +2041,27 @@
 socks%22, new 
-Complete
+Dfs
 Vertex());%0A%09
@@ -2083,32 +2083,27 @@
 shoes%22, new 
-Complete
+Dfs
 Vertex());%0A%09
@@ -2133,16 +2133,11 @@
 new 
-Complete
+Dfs
 Vert
@@ -2161,18 +2161,26 @@
 new 
-Old
 DiGraph
+%3CDfsVertex%3E
 (ver

Update unit tests for topological sort