public boolean doSearch(VertexType vertex, PreWorkHandler<VertexType> handler)
            throws InvalidVertexException {
        //int vertexId = vertex.getId();

        for (VertexType v : graph)
            v.setMark(false);

        vertex.setMark(true);
        LinkedList<VertexType> queue = new LinkedList<VertexType>();
        LinkedList<VertexType> roots = new LinkedList<VertexType>();
        queue.offer(vertex);
        roots.offer(vertex);
        try {
            while (queue.size() != 0) {
                VertexType index = queue.poll();
                VertexType root = roots.poll();

                if (handler != null)
                    if (handler.doPreWork(root, index))
                        return true;

                dispatchEvent(new PreWorkEvent<VertexType, EdgeType>(root, index, graph));
                EventUtils.algorithmStep(this, "explore: " + index.getId());


                for (VertexType i : graph) {
                    if (graph.isEdge(index, i) && !i.getMark()) {
                        i.setMark(true);
                        EventUtils.algorithmStep(this, "visit: " + i.getId());
                        queue.offer(i);
                        roots.offer(index);
                    }

                }
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return false;
    }