本文整理汇总了Java中vnreal.network.substrate.SubstrateNetwork.getEdges方法的典型用法代码示例。如果您正苦于以下问题:Java SubstrateNetwork.getEdges方法的具体用法?Java SubstrateNetwork.getEdges怎么用?Java SubstrateNetwork.getEdges使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vnreal.network.substrate.SubstrateNetwork
的用法示例。
在下文中一共展示了SubstrateNetwork.getEdges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateRandomBandwidthResources
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
public static void generateRandomBandwidthResources(
SubstrateNetwork sNetwork, int minResourceBandwidth,
int maxResourceBandwidth, Random random,
boolean useCommonConstraints) {
for (SubstrateLink l : sNetwork.getEdges()) {
int value = Utils.rnd(minResourceBandwidth, maxResourceBandwidth, random);
if (useCommonConstraints) {
CommonResource r = new CommonResource(value, l);
l.add(r);
} else {
BandwidthResource bw = new BandwidthResource(l);
bw.setBandwidth((double) value);
l.add(bw);
}
}
}
示例2: calculate
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
public double calculate(NetworkStack stack) {
double sum = 0.0;
int i = 0;
SubstrateNetwork sNetwork = stack.getSubstrate();
for (SubstrateLink sl : sNetwork.getEdges()) {
for (AbstractResource res : sl.get()) {
for (Mapping m : res.getMappings()) {
AbstractDemand dem = m.getDemand();
if (dem instanceof BandwidthDemand) {
sum += ((BandwidthDemand) dem).getDemandedBandwidth();
i++;
}
}
}
}
return (i == 0 ? 0.0 : (sum / (double) i));
}
示例3: calculate
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
public double calculate(NetworkStack stack) {
SubstrateNetwork sNetwork = stack.getSubstrate();
int sumLinkStress = 0;
int counter = 0;
for (SubstrateLink sl : sNetwork.getEdges()) {
int stress = Utils.getStressLevel(sl);
sumLinkStress += stress;
if (stress != 0) {
++counter;
}
}
if (counter == 0)
return Double.NaN;
return (sumLinkStress / (double) counter);
}
示例4: calcLinksRes
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
/**
*
* @param sn
* Substrate node
* @return The available resources of the node sn
*/
private double calcLinksRes(SubstrateNetwork sNet, SubstrateNode sn) {
SubstrateNode srcSnode = null;
double resBW = 0;
double total_resBW = 0;
for (SubstrateLink sl : sNet.getEdges()) {
srcSnode = sNet.getSource(sl);
// If the processing SubstrateNode is equals to the source of a
// SubstrateLink then add the link
if (sn.equals(srcSnode)) {
for (AbstractResource res : sl) {
if (res instanceof BandwidthResource) {
resBW = ((BandwidthResource) res)
.getAvailableBandwidth();
total_resBW += resBW;
}
}
}
}
return total_resBW;
}
示例5: removeDuplicateEdges
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
void removeDuplicateEdges(LockTree current, Collection<SubstrateLink> orig) {
if (current.getChildren() != null) {
for (LockTree c : current.getChildren()) {
SubstrateNetwork cc = current.getClusterHead().cluster;
for (SubstrateLink l : new LinkedList<SubstrateLink>(cc.getEdges())) {
boolean found = false;
for (SubstrateLink o : orig) {
if (o.getName().equals(l.getName())) {
found = true;
break;
}
}
if (!found) {
cc.removeEdge(l);
}
}
removeDuplicateEdges(c, orig);
}
}
}
示例6: generate
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
@Override
public List<CostResource> generate(ArrayList<Object> parameters) {
ArrayList<CostResource> resList = new ArrayList<CostResource>();
NetworkStack ns = (NetworkStack)parameters.get(0);
Integer minLC = ConversionHelper.paramObjectToInteger(parameters.get(1));
Integer maxLC = ConversionHelper.paramObjectToInteger(parameters.get(2));
Long seed = ConversionHelper.paramObjectToLong(parameters.get(3));
Random random = new Random();
random.setSeed(seed);
SubstrateNetwork sNet = ns.getSubstrate();
for (SubstrateLink l : sNet.getEdges()) {
CostResource bw = new CostResource(l);
int value = (int) (minLC + (maxLC
- minLC + 1)
* random.nextDouble());
bw.setCost((double) value);
l.add(bw);
resList.add(bw);
}
return resList;
}
示例7: generate
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
@Override
public List<BandwidthResource> generate(ArrayList<Object> parameters) {
ArrayList<BandwidthResource> resList = new ArrayList<BandwidthResource>();
NetworkStack ns = (NetworkStack)parameters.get(0);
Integer minBW = ConversionHelper.paramObjectToInteger(parameters.get(1));
Integer maxBW = ConversionHelper.paramObjectToInteger(parameters.get(2));
Long seed = ConversionHelper.paramObjectToLong(parameters.get(3));
Random random = new Random();
random.setSeed(seed);
SubstrateNetwork sNet = ns.getSubstrate();
for (SubstrateLink l : sNet.getEdges()) {
BandwidthResource bw = new BandwidthResource(l);
int value = (int) (minBW + random.nextInt(maxBW - minBW + 1));
bw.setBandwidth((double) value);
l.add(bw);
resList.add(bw);
}
return resList;
}
示例8: generate
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
@Override
public List<CostResource> generate(ArrayList<Object> parameters) {
ArrayList<CostResource> resList = new ArrayList<CostResource>();
NetworkStack ns = (NetworkStack)parameters.get(0);
Integer minLC = ConversionHelper.paramObjectToInteger(parameters.get(1));
Integer maxLC = ConversionHelper.paramObjectToInteger(parameters.get(2));
Random random = new Random();
SubstrateNetwork sNet = ns.getSubstrate();
for (SubstrateLink l : sNet.getEdges()) {
CostResource bw = new CostResource(l);
int value = (int) (minLC + (maxLC
- minLC + 1)
* random.nextDouble());
bw.setCost((double) value);
l.add(bw);
resList.add(bw);
}
return resList;
}
示例9: generate
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
@Override
public List<BandwidthResource> generate(ArrayList<Object> parameters) {
ArrayList<BandwidthResource> resList = new ArrayList<BandwidthResource>();
Random random = new Random();
NetworkStack ns = (NetworkStack)parameters.get(0);
Integer minBW = ConversionHelper.paramObjectToInteger(parameters.get(1));
Integer maxBW = ConversionHelper.paramObjectToInteger(parameters.get(2));
SubstrateNetwork sNet = ns.getSubstrate();
for (SubstrateLink l : sNet.getEdges()) {
BandwidthResource bw = new BandwidthResource(l);
int value = (int) (minBW + (maxBW
- minBW + 1)
* random.nextDouble());
bw.setBandwidth((double) value);
l.add(bw);
resList.add(bw);
}
return resList;
}
示例10: export
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
/**
* Export a SubstrateNetwork
* @param filename The file to write to
* @param snet The network to export
* @throws IOException
*/
public void export(String filename, SubstrateNetwork snet) throws IOException {
FileOutputStream outStream = new FileOutputStream(filename);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(outStream));
String firstLine = snet.isDirected() ? "digraph" : "graph";
String edge = snet.isDirected() ? " -> " : " -- ";
firstLine += " \"" + snet.getLabel() + "\" {\n";
bw.write(firstLine);
for (SubstrateNode sn: snet.getVertices()) {
bw.write("\t" + sn.getId() + ";\n");
}
for (SubstrateLink sl : snet.getEdges()) {
SubstrateNode n1 = snet.getSource(sl);
SubstrateNode n2 = snet.getDest(sl);
String line = "\t" + n1.getId() + edge + n2.getId() + ";\n";
bw.write(line);
}
bw.write("}");
bw.flush();
bw.close();
}
示例11: generateRandomDelayResources
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
public static void generateRandomDelayResources(SubstrateNetwork sNetwork,
int minDelayResource, int maxDelayResource, Random random) {
for (SubstrateLink n : sNetwork.getEdges()) {
int value = (int) (minDelayResource + (maxDelayResource
- minDelayResource + 1)
* random.nextDouble());
StaticDelayResource res = new StaticDelayResource(n, value);
n.add(res);
}
}
示例12: generateRandomBandwidthResources
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
public static void generateRandomBandwidthResources(
SubstrateNetwork sNetwork,
Integer[] bandwidthResources,
Random random) {
for (SubstrateLink l : sNetwork.getEdges()) {
BandwidthResource bw = new BandwidthResource(l);
int pos = Utils.rnd(0, bandwidthResources.length - 1, random);
int value = bandwidthResources[pos];
bw.setBandwidth((double) value);
l.add(bw);
}
}
示例13: generateRandomDelayResources
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
public static void generateRandomDelayResources(SubstrateNetwork network,
Integer[] DelayResources, Random random) {
for (SubstrateLink l : network.getEdges()) {
int pos = Utils.rnd(0, DelayResources.length - 1, random);
int value = DelayResources[pos];
l.add(new StaticDelayResource(l, value));
}
}
示例14: calculate
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
public double calculate(NetworkStack stack) {
SubstrateNetwork sNetwork = stack.getSubstrate();
int sumLinkStress = 0;
for (SubstrateLink sl : sNetwork.getEdges())
sumLinkStress += Utils.getStressLevel(sl);
return (sumLinkStress / (double) sNetwork.getEdges().size());
}
示例15: calculate
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
public double calculate(NetworkStack stack) {
SubstrateNetwork sNetwork = stack.getSubstrate();
int max = 0;
for (SubstrateLink sl : sNetwork.getEdges()) {
int stress = Utils.getStressLevel(sl);
if (stress > max) {
max = stress;
}
}
return max;
}