本文整理汇总了Java中vnreal.network.substrate.SubstrateNetwork.getOpposite方法的典型用法代码示例。如果您正苦于以下问题:Java SubstrateNetwork.getOpposite方法的具体用法?Java SubstrateNetwork.getOpposite怎么用?Java SubstrateNetwork.getOpposite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vnreal.network.substrate.SubstrateNetwork
的用法示例。
在下文中一共展示了SubstrateNetwork.getOpposite方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapLinks
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
/**
* mapping of links
*/
boolean mapLinks(VirtualNetwork vNetwork, SubstrateNetwork sNetwork,
NodeLinkMapping result) {
for (VirtualLink vl : vNetwork.getEdges()) {
Pair<VirtualNode> nodes = vNetwork.getEndpoints(vl);
SubstrateNode from = result.getSubstrateNode(nodes.getFirst());
SubstrateNode to = result.getSubstrateNode(nodes.getSecond());
if (from.getId() == to.getId()) {
continue;
}
SubstrateLinkStressTransformer transformer = new SubstrateLinkStressTransformer(
this, sNetwork, vl.get(), biggestLinkStress, delta_L);
DistanceEntry distance = getDistance(sNetwork, from, to,
transformer);
assert (distance == null || Utils.fulfills(distance.path, vl.get()));
if (distance == null) {
return false;
}
result.add(vl, distance.path);
demandedResources.addAll(Utils.occupyPathResources(vl,
distance.path, sNetwork));
SubstrateNode currentNode = from;
for (SubstrateLink sl : distance.path) {
double stress = getStressLevel(sNetwork, currentNode, sl);
if (stress > biggestLinkStress) {
biggestLinkStress = stress;
}
currentNode = sNetwork.getOpposite(currentNode, sl);
}
}
return true;
}
示例2: exportSubstrate
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
/**
* Export a SubstrateNetwork to a METIS GRAPH File
*
* @param substNetwork
* @throws IOException
* @return {(metisID, substrate node ID)}
*/
public static SubstrateNode[] exportSubstrate(SubstrateNetwork substNetwork, String fileName){
SubstrateNode[] nodes = substNetwork.getVertices().toArray(new SubstrateNode[0]);
HashMap<SubstrateNode, Integer> map = new HashMap<SubstrateNode, Integer>();
//assumption: the graph has both edge and vertex weights
int FMT = 11;
double nodeWeight;
double linkWeight;
SubstrateNode neighborNode;
SubstrateLink substLink;
//nodeID's are not consecutive
for(int i=0; i<nodes.length; i++){
map.put(nodes[i], i+1);
}
//the first line lists the number of nodes and the number of edges
try {
BufferedWriter metisFile = new BufferedWriter(new FileWriter(fileName));
metisFile.write(substNetwork.getVertices().size() + " ");
metisFile.write(substNetwork.getEdgeCount()/2 + " ");
metisFile.write(FMT + "");
//iterate over all the nodes
for (int metisID = 0; metisID < nodes.length; ++metisID) {
nodeWeight = getNodeWeight(nodes[metisID]);
//write in a file that node has nodeWeight
metisFile.newLine();
metisFile.write((int)nodeWeight +"");
Iterator<SubstrateLink> itrLink = substNetwork.getOutEdges(nodes[metisID]).iterator();
// iterate over all outgoing edges from a node
while(itrLink.hasNext()){
substLink = itrLink.next();
neighborNode = substNetwork.getOpposite(nodes[metisID], substLink);
// only if backward-edge exist
if(substNetwork.isSuccessor(neighborNode, nodes[metisID])){
linkWeight = getLinkWeight(substLink);
//is connected to node on an edge with weight
metisFile.write(" " + (map.get(neighborNode)) + " " + (int)linkWeight);
}else{
System.err.println("Error: Backward edge does not exist!");
}
}
}
metisFile.close();
} catch (IOException e) {
e.printStackTrace();
}
return nodes;
}