<commit_before>/**
 * 
 */
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 <NAME>
 * @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;
	}
}
<commit_msg>Update unit tests for topological sort<commit_after>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.graph.DiGraph;
import com.codemelon.graph.vertex.types.DfsVertex;

/**
 * @author <NAME>
 * @version Nov 27, 2012
 *
 */
public class TopologicalSortTest {
	private DiGraph<DfsVertex> 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, DfsVertex> 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, DfsVertex> setUpSmallCLRSGraph() {
		HashMap<String, DfsVertex> vertices = new HashMap<String, DfsVertex>();
		vertices.put("undershorts", new DfsVertex());
		vertices.put("pants", new DfsVertex());
		vertices.put("belt", new DfsVertex());
		vertices.put("shirt", new DfsVertex());
		vertices.put("tie", new DfsVertex());
		vertices.put("jacket", new DfsVertex());
		vertices.put("socks", new DfsVertex());
		vertices.put("shoes", new DfsVertex());
		vertices.put("watch", new DfsVertex());
		graph = new DiGraph<DfsVertex>(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;
	}
}

{'fraction_non_alphanumeric': 0.1759356418328087, 'fraction_numerical': 0.0031479538300104933, 'mean_word_length': 6.008578431372549, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6983799', 'n_tokens_mistral': 2050, 'n_tokens_neox': 1901, 'n_words': 300}