本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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};
}