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

cdc.graphs.impl.ImplicitSubGraph 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.function.IterableUtils;

/**
 * Base implementation of implicit subgraph.
 * 

* Concrete implementation must implement: *

    *
  • {@code containsNode}. *
  • {@code containsEdge} if necessary. * Default implementation accepts all edges that connect 2 accepted nodes. *
* * @author Damien Carbonne * * @param Node type. * @param Edge type. */ public abstract class ImplicitSubGraph extends GraphFilter { protected ImplicitSubGraph(GraphAdapter delegate) { super(delegate); } @Override public Iterable getNodes() { return IterableUtils.filter(delegate.getNodes(), this::containsNode); } @Override public Iterable getEdges() { return IterableUtils.filter(delegate.getEdges(), this::containsEdge); } @Override public boolean containsEdge(E edge) { return getDelegate().containsEdge(edge) && containsNode(getDelegate().getTip(edge, EdgeTip.SOURCE)) && containsNode(getDelegate().getTip(edge, EdgeTip.TARGET)); } @Override public Iterable getEdges(N node, EdgeDirection direction) { return IterableUtils.filter(delegate.getEdges(node, direction), this::containsEdge); } @Override public N getTip(E edge, EdgeTip tip) { return delegate.getTip(edge, tip); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy