I'm having trouble understanding everything in Skeina's algorithm to detect cycles in a graph whether directed or undirected

```
void process_edge(int v, int y) {
// if parent[v] == y it means we're visitng the same edge since this is unweighted?
// y must be discovered otherwise this is the first I'm seeing it?
if (discovered[y] && parent[v] != y) {
printf("\nfound a back edge (%d %d) \n", v, y);
}
}
void DFSRecursive(graph *g, int v) {
discovered[v] = true;
edge *e = g->edges[v];
while (e != NULL) {
int y = e->y;
if (discovered[y] == false) {
parent[y] = v;
DFSRecursive(g, y);
} else if (!processed[y] || g->directed) { // can't be processed and yet has an unvisited kid!?
process_edge(v, y, data);
}
e = e->next;
}
processed[v] = true;
}
```

- Why are we checking !processed[y]? If we see a neighbor y and it was discovered already (first if condition), how would it be possible that y has been processed? given that v is a neighbor and we discovered it just now?
- I was confused with the check for parent[v] !== y but I guess it makes sense in the unweighted graph case, if we have a graph with just two nodes, both nodes have each other in their adjacency so this is not a cycle. I'm not clear though on why it would make sense in the directed case because 1->2 and 2->1 is considered a cycle, right?
- I don't have problems with the third condition discovered[y] in the process edge method because if it undiscovered, it would mean this is the first time we are seeing it