<commit_before>import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;


public class Graph {

	class EdgeNode {
		int index;
		int weight;
		EdgeNode next;
		
		int degree;
		
	}
	
	EdgeNode[] edges;
	
	int max = 6;
	int nedges;
	boolean directed;
	
	public Graph(boolean directed) {
		edges = new EdgeNode[max];
		nedges = 0;
		this.directed = directed;
		
		insertEdge(1, 2, false);
		insertEdge(1, 5, false);
		insertEdge(2, 5, false);
		insertEdge(5, 4, false);
		insertEdge(4, 2, false);
		insertEdge(2, 3, false);
		insertEdge(4, 3, false);
	}
	
	public void insertEdge(int xIndex, int yIndex, boolean directed) {
		if (edges[xIndex] == null) {
			EdgeNode node = new EdgeNode();
			node.index = xIndex;
			edges[xIndex] = node;
		}
		EdgeNode node = (EdgeNode)edges[xIndex];
		node.degree++;
		while (node.next != null) {
			node = node.next;
		}
		EdgeNode nextNode = new EdgeNode();
		nextNode.index = yIndex;
		node.next = nextNode;
		
		if (directed) {
			nedges++;
		} else {
			insertEdge(yIndex, xIndex, true);
		}
	}
	
	public void printGraph() {
		for (int i = 0; i < max; i++) {
			System.out.println();
			EdgeNode node = edges[i];
			if (node == null) {
				continue;
			}
			System.out.print(node.index + ":");
			while (node.next != null) {
				node = node.next;
				System.out.print(node.index + ",");
			}
		}
	}
	
	public static void main(String[] args) {
		Graph graph = new Graph(false);
		graph.printGraph();
		graph.bfs(1);
	}
	
	public void bfs(int start) {
		Queue<Integer> queue = new LinkedList<Integer>();
		boolean[] visited = new boolean[max];
		boolean[] processed = new boolean[max];
		
		System.out.println();
		System.out.println("----");
		queue.add(start);
		System.out.print(edges[start].index + ",");
		visited[start] = true;
		
		while (!queue.isEmpty()) {
			int index = queue.poll();
			if (processed[index]) {
				continue;
			}
			EdgeNode node = edges[index];
			node = node.next;
			while (node != null) {
				if (!visited[node.index]) {
					System.out.print(node.index + ",");
					queue.add(node.index);
					visited[node.index] = true;
				}
				node = node.next;
			}
			processed[index] = true;
		}
	}
}<commit_msg>Added dfs algorithm<commit_after>import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Stack;


public class Graph {

	class EdgeNode {
		int index;
		int weight;
		EdgeNode next;
		
		int degree;
		
	}
	
	EdgeNode[] edges;
	
	static int max = 7;
	int nedges;
	boolean directed;
	
	public Graph(boolean directed) {
		edges = new EdgeNode[max];
		nedges = 0;
		this.directed = directed;
		
		insertEdge(1, 2, false);
		insertEdge(1, 5, false);
		insertEdge(1, 6, false);
		insertEdge(2, 5, false);
		insertEdge(5, 4, false);
		insertEdge(2, 3, false);
		insertEdge(4, 3, false);
	}
	
	public void insertEdge(int xIndex, int yIndex, boolean directed) {
		if (edges[xIndex] == null) {
			EdgeNode node = new EdgeNode();
			node.index = xIndex;
			edges[xIndex] = node;
		}
		EdgeNode node = (EdgeNode)edges[xIndex];
		node.degree++;
		while (node.next != null) {
			node = node.next;
		}
		EdgeNode nextNode = new EdgeNode();
		nextNode.index = yIndex;
		node.next = nextNode;
		
		if (directed) {
			nedges++;
		} else {
			insertEdge(yIndex, xIndex, true);
		}
	}
	
	public void printGraph() {
		for (int i = 0; i < max; i++) {
			System.out.println();
			EdgeNode node = edges[i];
			if (node == null) {
				continue;
			}
			System.out.print(node.index + ":");
			while (node.next != null) {
				node = node.next;
				System.out.print(node.index + ",");
			}
		}
	}
	
	
	public void bfs(int start) {
		Queue<Integer> queue = new LinkedList<Integer>();
		boolean[] visited = new boolean[max];
		boolean[] processed = new boolean[max];
		
		System.out.println();
		System.out.println("----");
		queue.add(start);
		System.out.print(edges[start].index + ",");
		visited[start] = true;
		
		while (!queue.isEmpty()) {
			int index = queue.poll();
			if (processed[index]) {
				continue;
			}
			EdgeNode node = edges[index];
			node = node.next;
			while (node != null) {
				if (!visited[node.index]) {
					System.out.print(node.index + ",");
					queue.add(node.index);
					visited[node.index] = true;
				}
				node = node.next;
			}
			processed[index] = true;
		}
	}
	
	
	static boolean[] dfs_discovered = new boolean[max];
	static boolean[] dfs_processed = new boolean[max];
	
	public void dfs(int start) {
		
		
		EdgeNode node = edges[start];
		if (!dfs_discovered[start]) {
			System.out.print(node.index + ",");
			dfs_discovered[start] = true;
			
			EdgeNode next = node.next;
			while (next != null) {
				dfs(next.index);
				next = next.next;
			}
		}
	}
	
	public static void main(String[] args) {
		Graph graph = new Graph(false);
		graph.printGraph();
		graph.bfs(1);
		System.out.println();
		System.out.println("----");
		graph.dfs(1);
	}
	
}
{'fraction_non_alphanumeric': 0.15881996362901596, 'fraction_numerical': 0.007476257829864619, 'mean_word_length': 3.0080971659919027, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 7, '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': '5954081', 'n_tokens_mistral': 2112, 'n_tokens_neox': 1746, 'n_words': 415}