E.g. I wonder if it is possible to compute the “layer” of all vertices of a directed tree using igraph::dfs(). Without using other functions that implicitly traverse the graph such as shortst_paths(), distances(), degree(), layout_with_sugiyama().
The layer of a vertex is (recursively) defined as
equal to zero if there are no outgoing edges and
otherwise the largest layer among the successors, plus 1.
It is straightforward to code this manually, but the native dfs() is obviously much faster.
@krlmlr, I suggest you try to do this before settling on a solution for the above issue.
Basically you need to iterate through vertices according to order.out, then whenever the parent p of a vertex v doesn’t have a higher stream order, set its stream order of p to that of the v plus one.
Note that it is not necessary to use the callback function.