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


Java SubstrateNetwork.getOpposite方法代码示例

本文整理汇总了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;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:42,代码来源:BasicVNAssignmentAlgorithm.java

示例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;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:69,代码来源:MetisIO.java


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