001/*
002 *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 *  This file is licensed to You under the Eclipse Public License (EPL);
005 *  You may not use this file except in compliance with the License. You
006 *  may obtain a copy of the License at
007 *
008 *      http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 *  See the COPYRIGHT.txt file distributed with this work for information
011 *  regarding copyright ownership.
012 */
013package org.jikesrvm.compilers.opt.util;
014
015import java.util.Enumeration;
016
017
018/**
019 *  This class generates an enumeration of nodes of a graph, in order
020 * of increasing finishing time in a reverse Depth First Search,
021 * i.e. a search traversing nodes from target to source.
022 */
023public class ReverseDFSenumerateByFinish extends DFSenumerateByFinish {
024
025  /**
026   *  Construct a reverse DFS across a graph.
027   *
028   * @param net The graph over which to search.
029   */
030  public ReverseDFSenumerateByFinish(Graph net) {
031    super(net);
032  }
033
034  /**
035   *  Construct a reverse DFS across a subset of a graph, starting
036   * at the given set of nodes.
037   *
038   * @param net The graph over which to search
039   * @param nodes The nodes at which to start the search
040   */
041  public ReverseDFSenumerateByFinish(Graph net, Enumeration<GraphNode> nodes) {
042    super(net, nodes);
043  }
044
045  /**
046   *  Traverse edges from target to source.
047   *
048   * @param n A node in the DFS
049   * @return The nodes that have edges leading to n
050   */
051  @Override
052  protected Enumeration<GraphNode> getConnected(GraphNode n) {
053    return n.inNodes();
054  }
055}
056
057
058