## CS367 Homework 6
| ||||||||||||||||||||||

## QuestionsWhat do I need to answer? Below is an *incomplete*definition of the`Graphnode`class.class Graphnode<T> { private boolean visitMark; private List<Graphnode<T>> successors; public boolean getVisitMark() { return visitMark; } public void setVisitMark(boolean mark) { visitMark = mark; } public List<Graphnode<T>> getSuccessors() { return successors; } } **Write the**This method takes a`hasSelfCycle`method whose header is provided below.`Graphnode node`and returns true iff there exists a path from`node`to itself (i.e., if there is a cycle in the graph that starts and ends at`node`). Your implementation must be based on the depth-first search algorithm (i.e., modify DFS to implement`hasSelfCycle`) and must exit early if possible.public boolean hasSelfCycle( Graphnode<T> node ) You may assume that all the nodes in the graph have been marked unvisited prior to the `hasSelfCycle`method being called and that there are no self edges (i.e., there are no edges from a node to itself). You may not modify the`Graphnode`class. You may find it helpful to write an auxiliary method.Given the following graph with nodes having character labels and edges having non-negative integer weights: **Trace Dijkstra's algorithm, starting at node S,**by filling in the remaining rows in the table below. Each row in the table represents one iteration of the of the algorithm, so use as many or as few rows as needed for the algorithm to complete.visited nodes and their shortest distances from startdist values for nodes in U (only finite values, listed in increasing order)- (0,S) S:0 (4,G), (11,H), (33,P) S:0, G:4 (10,R), (11,H), (11,P)
- Give
**three distinct topological orderings**of the following directed acyclic graph:
| ||||||||||||||||||||||

## Handing inPlease include your name at the top your file.
Put your answers to the questions into one file named Electronically submit your work to the Homework 6 tab on Canvas. | ||||||||||||||||||||||

Last Updated: 1/11/2018 © 2008-2018 CS367 Instructors |