当前位置: 首页>>代码示例>>Java>>正文


Java GraphPath类代码示例

本文整理汇总了Java中org.jgrapht.GraphPath的典型用法代码示例。如果您正苦于以下问题:Java GraphPath类的具体用法?Java GraphPath怎么用?Java GraphPath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GraphPath类属于org.jgrapht包,在下文中一共展示了GraphPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGraphConstruction

import org.jgrapht.GraphPath; //导入依赖的package包/类
@Test
public void testGraphConstruction() {
	Annotation exon1 = new BasicAnnotation("chr1", 1000, 1200,"+");
	Annotation exon2 = new BasicAnnotation("chr1", 1500, 1700,"+");
	Annotation exon3 = new BasicAnnotation("chr1", 1900, 2100,"+");
	List<Annotation> exonList1 = new ArrayList<Annotation> (3);
	
	exonList1.add(exon1); exonList1.add(exon2); exonList1.add(exon3);
	
	Annotation threeExonAnnotation = new BasicAnnotation(exonList1);
	
	List<Annotation> exonList2 = new ArrayList<Annotation> (2);
	exonList2.add(exon1);  exonList2.add(exon3);
	Annotation twoExonAnnotation = new BasicAnnotation(exonList2);
	
	OrientedChromosomeTranscriptGraph graph = new OrientedChromosomeTranscriptGraph("test","+");
	
	boolean couldAdd = graph.addAnnotationToGraph(threeExonAnnotation);
	assertTrue("Could not add positive annotation to positive graph!!!", couldAdd);
	couldAdd = graph.addAnnotationToGraph(twoExonAnnotation);
	assertTrue("Could not add positive annotation to positive graph!!!", couldAdd);
	//graph.addEdge(exon1, exon2);
	//graph.addEdge(exon2, exon3);
	//graph.addEdge(exon1, exon3);
	
	Collection<GraphPath<Annotation, TranscriptGraphEdge>> paths = graph.getPaths();
	
	for (GraphPath<Annotation, TranscriptGraphEdge> p : paths) {
		System.err.println(OrientedChromosomeTranscriptGraph.pathToGene(p));
	}
	
}
 
开发者ID:mgarber,项目名称:scriptureV2,代码行数:33,代码来源:OrientedChromosomeTranscriptGraphTest.java

示例2: getDistance

import org.jgrapht.GraphPath; //导入依赖的package包/类
/**
 * Calculates the distance between two regions in this map.<br>
 * <br>
 *
 * Distance is defined as the length of the shortest path in a graph representation of this map,
 * where two regions share an edge if and only if they are adjacent. All edges have weight / lenght 1.
 * <br>
 * If no path was found, {@link #getNumberOfRegions()}-1 is returned.
 */
public int getDistance(Region regionOne, Region regionTwo) {
    if (regionOne.equals(regionTwo)) {
        return 0;
    }
    GraphPath<Region, DefaultEdge> shortestPath = getFloyedWarshallDistances().getShortestPath(regionOne, regionTwo);
    if (shortestPath == null) {
        //No path found, return max distance
        return getNumberOfRegions() - 1;
    }
    List<DefaultEdge> path = shortestPath.getEdgeList();
    if (path == null) {
        //No path found, return max distance
        return getNumberOfRegions() - 1;
    }
    return path.size();
}
 
开发者ID:spectrumauctions,项目名称:sats-core,代码行数:26,代码来源:MRVMRegionsMap.java

示例3: computeKBestRoutesBetween

import org.jgrapht.GraphPath; //导入依赖的package包/类
@Override
public IList<IList<E>> computeKBestRoutesBetween(final IScope scope, final V source, final V target, final int k) {
	final Pair<V, V> pp = new Pair<V, V>(source, target);
	final IList<IList<E>> paths = GamaListFactory.create(Types.LIST.of(getType().getContentType()));
	final IList<IList<E>> sps = shortestPathComputed.get(pp);
	if (sps != null && sps.size() >= k) {
		for (final IList<E> sp : sps) {
			paths.add(GamaListFactory.create(scope, getType().getContentType(), sp));
		}
	} else {
		final KShortestPaths<V, E> kp = new KShortestPaths<V, E>(getProxyGraph(), k);

		final List<GraphPath<V, E>> pathsJGT = kp.getPaths(source, target);
		final IList<IList<E>> el = GamaListFactory.create(Types.LIST.of(getType().getContentType()));
		for (final GraphPath<V, E> p : pathsJGT) {
			paths.add(GamaListFactory.create(scope, getType().getContentType(), p.getEdgeList()));
			if (saveComputedShortestPaths) {
				el.add(GamaListFactory.create(scope, getType().getContentType(), p.getEdgeList()));
			}
		}
		if (saveComputedShortestPaths) {
			shortestPathComputed.put(pp, el);
		}
	}
	return paths;
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:27,代码来源:GamaGraph.java

示例4: getShortestsPathsBetween

import org.jgrapht.GraphPath; //导入依赖的package包/类
private List<GraphPath<TaxiNode, TaxiEdge>> getShortestsPathsBetween(TaxiNode tn0, TaxiNode tn1) {
	// in the cache?
	Map<TaxiNode, List<GraphPath<TaxiNode, TaxiEdge>>> pathsForTN0 = kShortestPathsCache.get(tn0);
	if (pathsForTN0 == null) {
		pathsForTN0 = new ConcurrentHashMap<>();
		kShortestPathsCache.put(tn0, pathsForTN0);
	}
	
	List<GraphPath<TaxiNode, TaxiEdge>> paths = pathsForTN0.get(tn1);
	if (paths == null) {
		if (SnapTracks.GLOBAL_DEBUG_SNAPPING_CACHE) printlnSafelyToSystemOut("kShortestPaths cache MISS " + tn0 + "--->" + tn1);
		KShortestPaths<TaxiNode, TaxiEdge> ksp = new KShortestPaths<TaxiNode, TaxiEdge>(graph, tn0, kForStage2PathReduction, maxHopsForStage2PathReduction);
		paths = ksp.getPaths(tn1);
		if (paths == null) { // no paths found: this can easily happen if we're limiting the length of the paths allowed using maxHops
			paths = Collections.emptyList();
		}
		
		pathsForTN0.put(tn1, paths);
	} else {
		if (SnapTracks.GLOBAL_DEBUG_SNAPPING_CACHE) printlnSafelyToSystemOut("kShortestPaths cache HIT " + tn0 + "--->" + tn1);
	}
	
	return paths;
}
 
开发者ID:gm-tools,项目名称:gm-tools,代码行数:25,代码来源:SnapTracksThread.java

示例5: PWrapper

import org.jgrapht.GraphPath; //导入依赖的package包/类
private List<Path> PWrapper(List<GraphPath<Annotation,BubbleEdge>> paths){
	
	List<Path> pw = new ArrayList<Path>();
	for(GraphPath<Annotation,BubbleEdge> p :paths){
		Path x = new Path();
		boolean sameOrientation = checkOrientation(p.getEdgeList());
		if(sameOrientation){
			x.addEdges(p.getEdgeList());
			pw.add(x);
		}
		else{
			//nothing
		}
		
	}
	if(pw.size()==0){
		return null;
	}
	return pw;
}
 
开发者ID:mgarber,项目名称:scriptureV2,代码行数:21,代码来源:ChromosomeWithBubblesJGraphT.java

示例6: getOrphanPaths

import org.jgrapht.GraphPath; //导入依赖的package包/类
/**
 * Returns all orphan paths in graph (self edges for orphan vertices)
 * @return
 */
public Collection<GraphPath<Annotation, TranscriptGraphEdge>> getOrphanPaths(){
	List<GraphPath<Annotation, TranscriptGraphEdge>> paths = new ArrayList<GraphPath<Annotation, TranscriptGraphEdge>>();
	
	Iterator<Annotation> iter=getOrphanVertices().iterator();
	//Iterate through all vertices
	while(iter.hasNext()){
		Annotation align=iter.next();
		
		//Form new edge
		List<TranscriptGraphEdge> edge=new ArrayList<TranscriptGraphEdge>();
		edge.add(new TranscriptGraphEdge(new BasicAnnotation(align.getChr(), align.getEnd(), align.getEnd())));
		//edge.setParent(this);
		GraphPath<Annotation, TranscriptGraphEdge> path=new GraphPathImpl<Annotation, TranscriptGraphEdge>(this, align, align,edge, 0);
		//edge.setNodeCount(align, getCount(align));
		paths.add(path);	
	}
	
	return paths;
}
 
开发者ID:mgarber,项目名称:scriptureV2,代码行数:24,代码来源:OrientedChromosomeTranscriptGraph.java

示例7: testAddingOverlappingExons

import org.jgrapht.GraphPath; //导入依赖的package包/类
public void testAddingOverlappingExons() {
	Annotation exon1 = new BasicAnnotation("chr1", 1000, 1200,"+");
	Annotation exon2 = new BasicAnnotation("chr1", 1500, 1700,"+");
	Annotation exon3 = new BasicAnnotation("chr1", 1100, 1200,"+");

	List<Annotation> exonList1 = new ArrayList<Annotation> (2);
	exonList1.add(exon1); exonList1.add(exon2); 
	Annotation exonAnnotation1 = new BasicAnnotation(exonList1);
	
	List<Annotation> exonList2 = new ArrayList<Annotation> (2);
	exonList2.add(exon3); exonList2.add(exon2); 
	Annotation exonAnnotation2 = new BasicAnnotation(exonList2);
	
	OrientedChromosomeTranscriptGraph graph = new OrientedChromosomeTranscriptGraph("test","+");
	
	graph.addAnnotationToGraph(exonAnnotation1);
	graph.addAnnotationToGraph(exonAnnotation2);
	Collection<GraphPath<Annotation, TranscriptGraphEdge>> paths = graph.getPaths();
	System.err.println("Adding overlapping exons test");
	for (GraphPath<Annotation, TranscriptGraphEdge> p : paths) {
		System.err.println(OrientedChromosomeTranscriptGraph.pathToGene(p));
	}
}
 
开发者ID:mgarber,项目名称:scriptureV2,代码行数:24,代码来源:OrientedChromosomeTranscriptGraphTest.java

示例8: testAddingReverseOrientedSubgraphs

import org.jgrapht.GraphPath; //导入依赖的package包/类
public void testAddingReverseOrientedSubgraphs() {
	Annotation exon1 = new BasicAnnotation("chr1", 1000, 1200,"-");
	Annotation exon2 = new BasicAnnotation("chr1", 1500, 1700,"-");
	Annotation exon3 = new BasicAnnotation("chr1", 1100, 1200,"-");

	List<Annotation> exonList1 = new ArrayList<Annotation> (2);
	exonList1.add(exon1); exonList1.add(exon2); 
	Annotation exonAnnotation1 = new BasicAnnotation(exonList1);
	
	List<Annotation> exonList2 = new ArrayList<Annotation> (2);
	exonList2.add(exon3); exonList2.add(exon2); 
	Annotation exonAnnotation2 = new BasicAnnotation(exonList2);
	System.err.println(exonAnnotation1);
	System.err.println(exonAnnotation2);
	OrientedChromosomeTranscriptGraph graph = new OrientedChromosomeTranscriptGraph("test","-");
	
	graph.addAnnotationToGraph(exonAnnotation1);
	graph.addAnnotationToGraph(exonAnnotation2);
	Collection<GraphPath<Annotation, TranscriptGraphEdge>> paths = graph.getPaths();
	
	System.err.println("testAddingReverseOrientedSubgraphs");
	for (GraphPath<Annotation, TranscriptGraphEdge> p : paths) {
		System.err.println(OrientedChromosomeTranscriptGraph.pathToGene(p));
	}
}
 
开发者ID:mgarber,项目名称:scriptureV2,代码行数:26,代码来源:OrientedChromosomeTranscriptGraphTest.java

示例9: getLongestShortestPath

import org.jgrapht.GraphPath; //导入依赖的package包/类
/**
 * Returns the length of the longest shortest path in the adjacency graph between the specified region and any other region.
 */
public int getLongestShortestPath(Region region) {
    Preconditions.checkArgument(adjacencyGraph.containsVertex(region));
    List<GraphPath<Region, DefaultEdge>> shortestPaths = getFloyedWarshallDistances().getShortestPaths();
    int max = 0;
    for (GraphPath<Region, DefaultEdge> candidatePath : shortestPaths) {
        int length = candidatePath.getEdgeList().size();
        if (length > max) {
            max = length;
        }
    }
    return max;
}
 
开发者ID:spectrumauctions,项目名称:sats-core,代码行数:16,代码来源:MRVMRegionsMap.java

示例10: calculate

import org.jgrapht.GraphPath; //导入依赖的package包/类
public static Route calculate(Network network, Station source, Station target, @Nullable ConnectionWeighter weighter, @Nullable IAlternativeQualifier qualifier) {
    // 1st part: find the shortest path
    GraphPath path = getShortestPath(network, source, target, weighter, qualifier);

    // 2nd part: turn the path into a Route
    return new Route(path);
}
 
开发者ID:gbl08ma,项目名称:underlx,代码行数:8,代码来源:Route.java

示例11: getShortestPath

import org.jgrapht.GraphPath; //导入依赖的package包/类
public static GraphPath getShortestPath(Network network, Stop source, Stop target, @Nullable IEdgeWeighter weighter) {
    List<Stop> possibleSources = new ArrayList<>(1);
    possibleSources.add(source);
    List<Stop> possibleTargets = new ArrayList<>(1);
    possibleTargets.add(target);
    return getShortestPath(network, possibleSources, possibleTargets, weighter);
}
 
开发者ID:gbl08ma,项目名称:underlx,代码行数:8,代码来源:Route.java

示例12: checkPathCompliance

import org.jgrapht.GraphPath; //导入依赖的package包/类
public boolean checkPathCompliance(GraphPath<Stop, Connection> otherPath) {
    if (otherPath.getEdgeList().size() == 0) {
        return checkPathStartsRoute(otherPath);
    }
    Connection lastConnection = otherPath.getEdgeList().get(otherPath.getEdgeList().size() - 1);
    return checkEdgeCompliance(lastConnection);
}
 
开发者ID:gbl08ma,项目名称:underlx,代码行数:8,代码来源:Route.java

示例13: checkPathStartsRoute

import org.jgrapht.GraphPath; //导入依赖的package包/类
public boolean checkPathStartsRoute(GraphPath<Stop, Connection> otherPath) {
    Station current = otherPath.getEndVertex().getStation();
    for (Connection c : path.getEdgeList()) {
        if (c.getSource().getStation() == current || c.getTarget().getStation() == current) {
            return true;
        }
    }
    return false;
}
 
开发者ID:gbl08ma,项目名称:underlx,代码行数:10,代码来源:Route.java

示例14: shortestCycle

import org.jgrapht.GraphPath; //导入依赖的package包/类
private static List<String> shortestCycle(DirectedGraph<String, DefaultEdge> graph)
{
    FloydWarshallShortestPaths<String, DefaultEdge> floyd = new FloydWarshallShortestPaths<>(graph);
    int minDistance = Integer.MAX_VALUE;
    String minSource = null;
    String minDestination = null;
    for (DefaultEdge edge : graph.edgeSet()) {
        String src = graph.getEdgeSource(edge);
        String dst = graph.getEdgeTarget(edge);
        int dist = (int) Math.round(floyd.shortestDistance(dst, src)); // from dst to src
        if (dist < 0) {
            continue;
        }
        if (dist < minDistance) {
            minDistance = dist;
            minSource = src;
            minDestination = dst;
        }
    }
    if (minSource == null) {
        return null;
    }
    GraphPath<String, DefaultEdge> shortestPath = floyd.getShortestPath(minDestination, minSource);
    List<String> pathVertexList = Graphs.getPathVertexList(shortestPath);
    // note: pathVertexList will be [a, a] instead of [a] when the shortest path is a loop edge
    if (!Objects.equals(shortestPath.getStartVertex(), shortestPath.getEndVertex())) {
        pathVertexList.add(pathVertexList.get(0));
    }
    return pathVertexList;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:31,代码来源:SqlQueryQueueManager.java

示例15: FloydWarshallShortestPathsGAMA

import org.jgrapht.GraphPath; //导入依赖的package包/类
public FloydWarshallShortestPathsGAMA(final GamaGraph<V, E> graph, final GamaIntMatrix matrix) {
	this.graph = graph;
	this.vertices = new ArrayList<V>(graph.getVertexMap().keySet());
	this.paths = new THashMap<Pair<V, V>, GraphPath<V, E>>();
	nShortestPaths = 0;
	this.matrix = matrix;
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:8,代码来源:FloydWarshallShortestPathsGAMA.java


注:本文中的org.jgrapht.GraphPath类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。