code: @SuppressWarnings("unchecked")
      private Set<Integer> getPredecessors(Graph g, Integer vertex) {
          // The DirectedGraph cast seems to change the return type of the set
          // from Set<Integer> to just Set
          if (g instanceof DirectedGraph) {
              DirectedGraph<?> dg = (DirectedGraph)g;
              return dg.predecessors(vertex);
          }
          else {
              return g.getNeighbors(vertex);
          }
      }
docs: Returns those vertices that point to from {@code vertex} or all the
  adjacent vertices if {@code g} is not a directed graph.