org.jgrapht.EdgeFactory Java Examples

The following examples show how to use org.jgrapht.EdgeFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MinimumSteinerTreeApproximation.java    From jReto with MIT License 5 votes vote down vote up
/**
   * Computes the metric closure with a given set of vertices over a graph.
   * @param originalGraph The Graph over which the metric closure should be computed.
   * @param destinations A set of vertices which should exist in the metric closure.
   * @return A Graph that uses MetricClosureEdgeAnnotations that store the paths in the original graph to allow later reconstruction.
   */
public static <T, E> DirectedWeightedPseudograph<T, MetricClosureEdge<T>> createMetricClosure(DirectedWeightedPseudograph<T, E> originalGraph, Set<T> destinations) {
	DirectedWeightedPseudograph<T, MetricClosureEdge<T>> metricClosure = new DirectedWeightedPseudograph<>(new EdgeFactory<T, MetricClosureEdge<T>>() {
		@Override
		public MetricClosureEdge<T> createEdge(T sourceVertex, T targetVertex) {
			return new MetricClosureEdge<>(new ArrayList<T>());
		}
	});
	
	for (E edge : originalGraph.edgeSet()) {
		T start = originalGraph.getEdgeSource(edge);
		T end = originalGraph.getEdgeTarget(edge);
		
		metricClosure.addVertex(start);
		metricClosure.addVertex(end);
		MetricClosureEdge<T> newEdge = metricClosure.addEdge(start, end);
		double edgeWeight = originalGraph.getEdgeWeight(edge);
		metricClosure.setEdgeWeight(newEdge, edgeWeight);
	}
	
	Set<T> removedVertices = new HashSet<T>(originalGraph.vertexSet());
	removedVertices.removeAll(destinations);
	
	for (T removedVertex : removedVertices) {
		eliminateVertex(metricClosure, removedVertex);
	}
	
	return metricClosure;
}
 
Example #2
Source File: BaseGraph.java    From gatk-protected with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Construct a TestGraph with kmerSize
 * @param kmerSize
 */
protected BaseGraph(final int kmerSize, final EdgeFactory<V,E> edgeFactory) {
    super(edgeFactory);
    Utils.validateArg(kmerSize > 0, () -> "kmerSize must be > 0 but got " + kmerSize);
    this.kmerSize = kmerSize;
}
 
Example #3
Source File: GamaGraph.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EdgeFactory getEdgeFactory() {
	return null; // NOT USED
}
 
Example #4
Source File: BaseGraph.java    From gatk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Construct a TestGraph with kmerSize
 * @param kmerSize
 */
protected BaseGraph(final int kmerSize, final EdgeFactory<V,E> edgeFactory) {
    super(edgeFactory);
    Utils.validateArg(kmerSize > 0, () -> "kmerSize must be > 0 but got " + kmerSize);
    this.kmerSize = kmerSize;
}
 
Example #5
Source File: AbstractReadThreadingGraph.java    From gatk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
AbstractReadThreadingGraph(int kmerSize, EdgeFactory<MultiDeBruijnVertex, MultiSampleEdge> edgeFactory) {
    super(kmerSize, edgeFactory);
    debugGraphTransformations = false;
    minBaseQualityToUseInAssembly = 0;
}
 
Example #6
Source File: TestDigraph.java    From JTAF-XCore with Apache License 2.0 4 votes vote down vote up
public TestDigraph(EdgeFactory<DiNode, DiEdge> arg0) {
	super(arg0, true, true);
}
 
Example #7
Source File: ReadThreadingGraph.java    From gatk-protected with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Constructs a read-threading-graph for a string representation.
 *
 * <p>
 *     Note: only used for testing.
 * </p>
 * @param s the string representation of the graph {@code null}.
 */
@VisibleForTesting
protected ReadThreadingGraph(final int kmerSizeFromString, final EdgeFactory<MultiDeBruijnVertex, MultiSampleEdge> edgeFactory) {
    super(kmerSizeFromString, new MyEdgeFactory(1));
    debugGraphTransformations = false;
    minBaseQualityToUseInAssembly = 0;
}
 
Example #8
Source File: ReadThreadingGraph.java    From gatk with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Constructs a read-threading-graph for a string representation.
 *
 * <p>
 *     Note: only used for testing.
 * </p>
 */
@VisibleForTesting
protected ReadThreadingGraph(final int kmerSizeFromString, final EdgeFactory<MultiDeBruijnVertex, MultiSampleEdge> edgeFactory) {
    super(kmerSizeFromString, new MyEdgeFactory(1));
    nonUniqueKmers = null;
}