class TarjanGraphSearch implements GraphSearch<V, E> {

    @Override
    public SccResult<V, E> search(Graph<V, E> graph, EdgeWeight<V, E> weight) {
        SccResult<V, E> result = new SccResult<>(graph);
        for (V vertex : graph.getVertexes()) {
            VertexData data = result.data(vertex);
            if (data == null) {
                connect(graph, vertex, weight, result);
            }
        }
        return result.build();
    }

}