class HashReversibleGraph<N> extends HashMutableDirectedGraph<N> implements ReversibleGraph<N> {
  protected boolean reversed;

  public HashReversibleGraph(DirectedGraph<N> dg) {
    this();

    for (N s : dg) {
      addNode(s);
    }

    for (N s : dg) {
      for (N t : dg.getSuccsOf(s)) {
        addEdge(s, t);
      }
    }

    /* use the same heads and tails as the original graph */
    heads.clear();
    heads.addAll(dg.getHeads());
    tails.clear();
    tails.addAll(dg.getTails());
  }

  public HashReversibleGraph() {
    super();
    reversed = false;
  }

  @Override
  public boolean isReversed() {
    return reversed;
  }

  @Override
  public ReversibleGraph<N> reverse() {
    reversed = !reversed;
    return this;
  }

  @Override
  public void addEdge(N from, N to) {<FILL_FUNCTION_BODY>}

  @Override
  public void removeEdge(N from, N to) {
    if (reversed) {
      super.removeEdge(to, from);
    } else {
      super.removeEdge(from, to);
    }
  }

  @Override
  public boolean containsEdge(N from, N to) {
    return reversed ? super.containsEdge(to, from) : super.containsEdge(from, to);
  }

  @Override
  public List<N> getHeads() {
    return reversed ? super.getTails() : super.getHeads();
  }

  @Override
  public List<N> getTails() {
    return reversed ? super.getHeads() : super.getTails();
  }

  @Override
  public List<N> getPredsOf(N s) {
    return reversed ? super.getSuccsOf(s) : super.getPredsOf(s);
  }

  @Override
  public List<N> getSuccsOf(N s) {
    return reversed ? super.getPredsOf(s) : super.getSuccsOf(s);
  }
}

    if (reversed) {
      super.addEdge(to, from);
    } else {
      super.addEdge(from, to);
    }
  
<methods>public void <init>() ,public void <init>(HashMutableDirectedGraph<N>) ,public void addEdge(N, N) ,public void addNode(N) ,public void clearAll() ,public java.lang.Object clone() ,public boolean containsEdge(N, N) ,public boolean containsNode(N) ,public List<N> getHeads() ,public List<N> getNodes() ,public List<N> getPredsOf(N) ,public Set<N> getPredsOfAsSet(N) ,public List<N> getSuccsOf(N) ,public Set<N> getSuccsOfAsSet(N) ,public List<N> getTails() ,public Iterator<N> iterator() ,public void printGraph() ,public void removeEdge(N, N) ,public void removeNode(N) ,public int size() <variables>protected final non-sealed Set<N> heads,private static final org.slf4j.Logger logger,protected final non-sealed Map<N,Set<N>> nodeToPreds,protected final non-sealed Map<N,Set<N>> nodeToSuccs,protected final non-sealed Set<N> tails