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

- A jack system will increase the potential energy of a heavy load by 1000 J with a work input of 2000 J . The efficiency of the jack system is

- A 2500-N pile-driver ram falls 10 m and drives a post 0.1 m into the ground . The average impact force on the ram is

- A 2-kg mass is held 4 m above the ground . What is the approximate potential energy of the mass with respect to the ground ?