import java.util.*; /** * Library for graph analysis * * @author Chris Bailey-Kellogg, Dartmouth CS 10, Fall 2016 * @author Tim Pierson, Dartmouth CS10, provided for Winter 2025 * */ public class GraphLib { /** * Takes a random walk from a vertex, up to a given number of steps * So a 0-step path only includes start, while a 1-step path includes start and one of its out-neighbors, * and a 2-step path includes start, an out-neighbor, and one of the out-neighbor's out-neighbors * Stops earlier if no step can be taken (i.e., reach a vertex with no out-edge) * @param g graph to walk on * @param start initial vertex (assumed to be in graph) * @param steps max number of steps * @return a list of vertices starting with start, each with an edge to the sequentially next in the list; * null if start isn't in graph */ public static List randomWalk(Graph g, V start, int steps) { // TODO: your code here } /** * Orders vertices in decreasing order by their in-degree * @param g graph * @return list of vertices sorted by in-degree, decreasing (i.e., largest at index 0) */ public static List verticesByInDegree(Graph g) { // TODO: your code here } }