001    // GraphLab Project: http://graphlab.sharif.edu
002    // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology
003    // Distributed under the terms of the GNU Lesser General Public License (LGPL): http://www.gnu.org/licenses/
004    
005    /*
006     * PreWorkHandler.java
007     *
008     * Created on November 15, 2004, 3:13 AM
009     */
010    
011    package graphlab.library.event.handlers;
012    
013    import graphlab.library.BaseVertex;
014    
015    /**
016     * Handles prework used by algorithms such as BFS and DFS.
017     * Depending on the application, the user can define custom classes that
018     * implements PreWorkHandler and pass them to algorithms.
019     *
020     * @author Omid Aladini
021     */
022    public interface PreWorkHandler<VertexType extends BaseVertex> {
023        /**
024         * Does prework on a vertex of a graph.
025         *
026         * @param fromVertex Reference to the vertex we just leaved.
027         * @param toVertex   Reference to the vertex which prework will apply on.
028         * @return whether the traversal should stop at this point.
029         */
030        public boolean doPreWork(VertexType fromVertex, VertexType toVertex);
031    }