code: private void topologicalSortVisit(V n, List<V> L, Set<V> visited, LinkedHashSet<V> sequence) throws CycleException, EX {
  		//    if n has not been visited yet then
  		//        mark n as visited
  		if(visited.add(n)) {
  			//        for each node m with an edge from n to m do
  			for(Edge<V> e : (isForward ? graph.getEdgesFrom(n) : graph.getEdgesTo(n))) {
  				V m = isForward ? e.getTo() : e.getFrom();
  				//            visit(m)
  				if(!sequence.add(m)) {
  					List<V> vertices = new ArrayList<>();
  					boolean found = false;
  					for(V seq : sequence) {
  						if(!found && seq.equals(m)) found = true;
  						if(found) vertices.add(seq);
  					}
  					vertices.add(m);
  					throw new CycleException(AoCollections.optimalUnmodifiableList(vertices));
  				}
  				topologicalSortVisit(m, L, visited, sequence);
  				sequence.remove(m);
  			}
  			//        add n to L
  			L.add(n);
  		}
  	}
docs: function visit(node n)