All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cdc.graphs.impl.InvertedGraph Maven / Gradle / Ivy

There is a newer version: 0.71.2
Show newest version
package cdc.graphs.impl;

import cdc.graphs.EdgeDirection;
import cdc.graphs.EdgeTip;
import cdc.graphs.GraphAdapter;
import cdc.util.lang.Checks;

/**
 * Create an inverted view of a Graph. Nodes are the same, edges are the same,
 * except that their direction is inverted.
 *
 * @author Damien Carbonne
 *
 * @param  Node class
 * @param  Edge class
 */
public class InvertedGraph extends GraphFilter {
    public InvertedGraph(GraphAdapter delegate) {
        super(delegate);
    }

    @Override
    public final Iterable getNodes() {
        return delegate.getNodes();
    }

    @Override
    public final boolean containsNode(N node) {
        return delegate.containsNode(node);
    }

    @Override
    public final Iterable getEdges() {
        return delegate.getEdges();
    }

    @Override
    public final boolean containsEdge(E edge) {
        return delegate.containsEdge(edge);
    }

    @Override
    public final Iterable getEdges(N node,
                                                EdgeDirection direction) {
        if (direction == null) {
            return delegate.getEdges(node);
        } else {
            return delegate.getEdges(node, direction.opposite());
        }
    }

    @Override
    public final N getTip(E edge,
                          EdgeTip tip) {
        Checks.isNotNull(tip, "tip");
        return delegate.getTip(edge, tip.opposite());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy