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 hasSelfCycle method whose header is provided below.** This method takes a 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 use auxiliary method.

### Recently Asked Questions

- Please refer to the attachment to answer this question. This question was created from Week 4 Excel problem Level 1,2,3.docx.

- Please refer to the attachment to answer this question. This question was created from Week 4 Excel problem Level 1,2,3.docx.

- I have a silly question. Hopefully tutors can help me with a question : what structure should a Discussion Board and a Critical Analysis follow???