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


Java DijkstraShortestPath.getPath方法代码示例

本文整理汇总了Java中org.jgrapht.alg.DijkstraShortestPath.getPath方法的典型用法代码示例。如果您正苦于以下问题:Java DijkstraShortestPath.getPath方法的具体用法?Java DijkstraShortestPath.getPath怎么用?Java DijkstraShortestPath.getPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jgrapht.alg.DijkstraShortestPath的用法示例。


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

示例1: getDestinos

import org.jgrapht.alg.DijkstraShortestPath; //导入方法依赖的package包/类
public List<Integer> getDestinos(int inicio, int tirada){
	List<Integer> destinos = new ArrayList<Integer>();
	for (int i = 0; i < casillas.length; i++) {
		DijkstraShortestPath<Casilla, DefaultEdge> dijkstra = new DijkstraShortestPath<Casilla, DefaultEdge>(
				grafo, casillas[inicio], casillas[i]);
		GraphPath<Casilla, DefaultEdge> path = dijkstra.getPath();
		if (path.getWeight() == tirada)
			destinos.add(i);
	}
	return destinos;
}
 
开发者ID:Arquisoft,项目名称:Trivial4b,代码行数:12,代码来源:Grafo.java

示例2:

import org.jgrapht.alg.DijkstraShortestPath; //导入方法依赖的package包/类
public static GraphPath<Object,IntraDomainEdge> get_op2 
(SimpleDirectedWeightedGraph<Object, IntraDomainEdge> Graph, 
		Object src, Object dst, float bwt_req, Lock graphLock){
	
	SimpleDirectedWeightedGraph<Object,IntraDomainEdge> constrained_graph = new SimpleDirectedWeightedGraph<Object,IntraDomainEdge>(IntraDomainEdge.class);
	GraphPath<Object,IntraDomainEdge> gp = null;
	graphLock.lock();
	try{
		constrained_graph= (SimpleDirectedWeightedGraph<Object, IntraDomainEdge>) Graph.clone();
				
		Set<IntraDomainEdge> links1 = Graph.edgeSet();
		Iterator<IntraDomainEdge> iteredges1 = links1.iterator();
		IntraDomainEdge link1;
		while (iteredges1.hasNext())
		{
			link1 = iteredges1.next();  //IP of the current node
			// borramos los links que no tengan suficiente ancho de banda
			if ((link1.getTE_info().getMaximumReservableBandwidth().maximumReservableBandwidth)<bwt_req){
					constrained_graph.removeEdge(link1);
			}
		}
		/*System.out.println("PINTAMOS LA TOPOLOGía IP con CAPACIDAD SUFICIENTE");
		Set<IntraDomainEdge> links = constrained_graph.edgeSet();
		Iterator<IntraDomainEdge> iteredges = links.iterator();
		IntraDomainEdge link;
		while (iteredges.hasNext())
		{
			link = iteredges.next();  //IP of the current node
			System.out.println(link.toString()+"  BW -->"+link.getTE_info().getUnreservedBandwidth().getUnreservedBandwidth()[0]);
		}
		System.out.println("TERMINAMOS DE PINTAR");*/
		DijkstraShortestPath<Object,IntraDomainEdge>  dsp=new DijkstraShortestPath<Object,IntraDomainEdge> (constrained_graph, src, dst);
		gp=dsp.getPath();
		
	}finally{
		graphLock.unlock();
	}
	
	return gp;
}
 
开发者ID:telefonicaid,项目名称:netphony-pce,代码行数:41,代码来源:Operacion2.java

示例3: get_op1

import org.jgrapht.alg.DijkstraShortestPath; //导入方法依赖的package包/类
public static GraphPath<Object,IntraDomainEdge> get_op1 (SimpleDirectedWeightedGraph<Object
		, IntraDomainEdge> Graph, Object src, Object dst, Lock graphLock, float bwt_req){
	
	SimpleDirectedWeightedGraph<Object,IntraDomainEdge> constrained_graph = new SimpleDirectedWeightedGraph<Object,IntraDomainEdge>(IntraDomainEdge.class);
	GraphPath<Object,IntraDomainEdge> gp = null;
	graphLock.lock();
	try{
		constrained_graph= (SimpleDirectedWeightedGraph<Object, IntraDomainEdge>) Graph.clone();
			
		Set<IntraDomainEdge> links1 = Graph.edgeSet();
		Iterator<IntraDomainEdge> iteredges1 = links1.iterator();
		IntraDomainEdge link1;
				
		while (iteredges1.hasNext())
		{
			link1 = iteredges1.next();  //IP of the current node
			// borramos los links que no tengan suficiente ancho de banda
			
			if ((link1.getTE_info().getMaximumReservableBandwidth().maximumReservableBandwidth)<bwt_req){
				constrained_graph.removeEdge(link1);
			}
		}
		DijkstraShortestPath<Object,IntraDomainEdge>  dsp=new DijkstraShortestPath<Object,IntraDomainEdge> (constrained_graph, src, dst);
		gp=dsp.getPath();
	} finally{
		graphLock.unlock();
	}
	
	return gp;
}
 
开发者ID:telefonicaid,项目名称:netphony-pce,代码行数:31,代码来源:Operacion12.java

示例4: getNodePair

import org.jgrapht.alg.DijkstraShortestPath; //导入方法依赖的package包/类
/**
 * @return the pair of nodes belonging to the specified edges that are nearest or furthest apart.
 * These will be nulls if no connection could be found!
 * @return TaxiNode leftNode, TaxiNode rightNode, GraphPath<TaxiNode, TaxiEdge> shortestPath
 */
public static Object[] getNodePair(WeightedMultigraph<TaxiNode, TaxiEdge> graph, TaxiEdge leftEdge, TaxiEdge rightEdge, boolean nearest) {
	double best = nearest ? Double.POSITIVE_INFINITY : Double.NEGATIVE_INFINITY;
	TaxiNode leftNode = null;
	TaxiNode rightNode = null;
	GraphPath<TaxiNode, TaxiEdge> shortestPath = null;
	
	DijkstraShortestPath<TaxiNode, TaxiEdge> dsp = new DijkstraShortestPath<TaxiNode, TaxiEdge>(graph, leftEdge.getTnFrom(), rightEdge.getTnFrom());
	double length = dsp.getPathLength();
	if (nearest ? length < best : length > best) {
		leftNode = leftEdge.getTnFrom();
		rightNode = rightEdge.getTnFrom();
		best = length;
		shortestPath = dsp.getPath();
	}
	
	dsp = new DijkstraShortestPath<TaxiNode, TaxiEdge>(graph, leftEdge.getTnFrom(), rightEdge.getTnTo());
	length = dsp.getPathLength();
	if (nearest ? length < best : length > best) {
		leftNode = leftEdge.getTnFrom();
		rightNode = rightEdge.getTnTo();
		best = length;
		shortestPath = dsp.getPath();
	}
	
	dsp = new DijkstraShortestPath<TaxiNode, TaxiEdge>(graph, leftEdge.getTnTo(), rightEdge.getTnFrom());
	length = dsp.getPathLength();
	if (nearest ? length < best : length > best) {
		leftNode = leftEdge.getTnTo();
		rightNode = rightEdge.getTnFrom();
		best = length;
		shortestPath = dsp.getPath();
	}
	
	dsp = new DijkstraShortestPath<TaxiNode, TaxiEdge>(graph, leftEdge.getTnTo(), rightEdge.getTnTo());
	length = dsp.getPathLength();
	if (nearest ? length < best : length > best) {
		leftNode = leftEdge.getTnTo();
		rightNode = rightEdge.getTnTo();
		best = length;
		shortestPath = dsp.getPath();
	}
	
	return new Object[] {leftNode, rightNode, shortestPath};
}
 
开发者ID:gm-tools,项目名称:gm-tools,代码行数:50,代码来源:SnapTracksThread.java


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