<commit_before>package engine;

import java.util.List;
import java.util.Map;

/**
 * This class provides access to all of the algorithms found
 * in the Centrality, Flow, and Search classes.  It is the external
 * API for the Graph Toolkit.
 *
 */
public class GraphToolkit {
    private GraphToolkit() {
        // This is not supposed to be instantiated
        throw new IllegalStateException();
    }

    /**
     * A BFS Implementation to find the shortest path from src to tgt. Since
     * this is BFS, the shortest path is in terms of length, not weights.
     *
     * @param g    the Graph
     * @param src  the node to start BFS from
     * @param tgt  the node to end BFS at
     * @param flow whether or not this is BFS on a flow graph
     * @return the shortest path from src to tgt.
     */
    public static List<Node> bfs(Graph g, Node src, Node tgt, boolean flow) {
        return Search.bfs(g, src, tgt, flow);
    }
    
    public static Map<Node, List<Integer>> dfsTree(Graph g, Node src) {
        return Search.dfsTree(g, src);
    }
    
    public static Map<Node, List<Integer>> dfsForest(Graph g, Node src) {
        return Search.dfsForest(g, src);
    }

    public static void getSCC(Graph g) {
        // TODO: Implement
        // Also return something
        // Implement Kosaraju's Algorithm for finding SCCs
    }
    
    public static List<Node> topSort(Graph g) {
    	return Search.topSort(g); 
    }
    
    public static boolean detectCycle(Graph g) {
    	return Search.detectCycle(g); 
    }


    /**
     * Finds all-pairs shortest paths by implementing the
     * Floyd-Warshall algorithm
     *
     * @param g the input graph
     * @return a map representing the all-pairs shortest path matrix
     */
    public static Map<Node, Map<Node, Double>> allPairsShortestPath(Graph g) {
        return Search.floydWarshall(g);
    }

    /**
     * Implement the Ford-Fulkerson algorithm for finding maximum flow on a
     * network.
     *
     * @param g   The graph to find
     * @param src the starting node
     * @param tgt the ending node
     * @return the maximum flow from src -> tgt on the graph g
     */
    public static int maxFlow(Graph g, Node src, Node tgt) {
        return Flow.maxFlow(g, src, tgt);
    }

    /**
     * Calculates the betweeness centrality for each node using Brandes'
     * algorithm.
     *
     * @param g the Graph whose values should be calculated
     * @return a map containing the betweeness centrality values
     */
    public static Map<Node, Double> btwCentrality(Graph g) {
        return Centrality.btwCentrality(g);
    }

    public static void commDetection(Graph g) {
        Centrality.commDetection(g);
    }

    /**
     * Find the Eigenvector Centrality of a graph
     * using the dampened PageRank formula
     *
     * @param g the graph to run PageRank on
     * @return a map from node id to rank
     */
    public static Map<Integer, Double> pageRank(Graph g) {
        return Centrality.pageRank(g);
    }
}
<commit_msg>Add GraphTookit function for Single-Source Shortest Path<commit_after>package engine;

import java.util.List;
import java.util.Map;

/**
 * This class provides access to all of the algorithms found
 * in the Centrality, Flow, and Search classes.  It is the external
 * API for the Graph Toolkit.
 *
 */
public class GraphToolkit {
    private GraphToolkit() {
        // This is not supposed to be instantiated
        throw new IllegalStateException();
    }

    /**
     * A BFS Implementation to find the shortest path from src to tgt. Since
     * this is BFS, the shortest path is in terms of length, not weights.
     *
     * @param g    the Graph
     * @param src  the node to start BFS from
     * @param tgt  the node to end BFS at
     * @param flow whether or not this is BFS on a flow graph
     * @return the shortest path from src to tgt.
     */
    public static List<Node> bfs(Graph g, Node src, Node tgt, boolean flow) {
        return Search.bfs(g, src, tgt, flow);
    }
    
    public static Map<Node, List<Integer>> dfsTree(Graph g, Node src) {
        return Search.dfsTree(g, src);
    }
    
    public static Map<Node, List<Integer>> dfsForest(Graph g, Node src) {
        return Search.dfsForest(g, src);
    }

    public static void getSCC(Graph g) {
        // TODO: Implement
        // Also return something
        // Implement Kosaraju's Algorithm for finding SCCs
    }
    
    public static List<Node> topSort(Graph g) {
    	return Search.topSort(g); 
    }
    
    public static boolean detectCycle(Graph g) {
    	return Search.detectCycle(g); 
    }

    /**
     * Finds single-source shortest paths by implementing the Bellman-Ford
     * algorithm
     *
     * @param g the input graph
     * @param src the starting node
     * @return a map with shortest paths distances from src to every other node
     */
    public static Map<Node, Double> singleSourceShortestPath(Graph g, Node src) {
        if (g == null || src == null) {
            throw new IllegalArgumentException("Null input");
        }

        return Search.bellmanFord(g, src);
    }

    /**
     * Finds all-pairs shortest paths by implementing the
     * Floyd-Warshall algorithm
     *
     * @param g the input graph
     * @return a map representing the all-pairs shortest path matrix
     */
    public static Map<Node, Map<Node, Double>> allPairsShortestPath(Graph g) {
        return Search.floydWarshall(g);
    }

    /**
     * Implement the Ford-Fulkerson algorithm for finding maximum flow on a
     * network.
     *
     * @param g   The graph to find
     * @param src the starting node
     * @param tgt the ending node
     * @return the maximum flow from src -> tgt on the graph g
     */
    public static int maxFlow(Graph g, Node src, Node tgt) {
        return Flow.maxFlow(g, src, tgt);
    }

    /**
     * Calculates the betweeness centrality for each node using Brandes'
     * algorithm.
     *
     * @param g the Graph whose values should be calculated
     * @return a map containing the betweeness centrality values
     */
    public static Map<Node, Double> btwCentrality(Graph g) {
        return Centrality.btwCentrality(g);
    }

    public static void commDetection(Graph g) {
        Centrality.commDetection(g);
    }

    /**
     * Find the Eigenvector Centrality of a graph
     * using the dampened PageRank formula
     *
     * @param g the graph to run PageRank on
     * @return a map from node id to rank
     */
    public static Map<Integer, Double> pageRank(Graph g) {
        return Centrality.pageRank(g);
    }
}

{'fraction_non_alphanumeric': 0.08217732207478891, 'fraction_numerical': 0.0, 'mean_word_length': 2.3298192771084336, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 26, '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': '1436553', 'n_tokens_mistral': 1960, 'n_tokens_neox': 1926, 'n_words': 740}