本文整理汇总了Java中org.graphstream.graph.Node.getNeighborNodeIterator方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getNeighborNodeIterator方法的具体用法?Java Node.getNeighborNodeIterator怎么用?Java Node.getNeighborNodeIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.graphstream.graph.Node
的用法示例。
在下文中一共展示了Node.getNeighborNodeIterator方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeFile
import org.graphstream.graph.Node; //导入方法依赖的package包/类
private void writeFile() {
nodesTrav.remove(0);
for (Node node : nodesTrav) {
String s = "";
if (node.getDegree() == 0) {
s = " ";
} else {
Iterator<Node> nNeigh = node.getNeighborNodeIterator();
while(nNeigh.hasNext()) {
Node u = nNeigh.next();
s += " " + mapNode.get(u);
}
}
printerOut.print('\n' + s);
}
}
示例2: getIntersectionNodes
import org.graphstream.graph.Node; //导入方法依赖的package包/类
public List<Node> getIntersectionNodes(Node v, Integer partitionIndex) throws PartitionOutOfBoundException {
checkIndex(partitionIndex);
Iterator<Node> vNeigh = v.getNeighborNodeIterator();
List<Node> intersection = new ArrayList<Node>(1);
while (vNeigh.hasNext()) {
Node u = vNeigh.next();
if (!u.hasAttribute(GraphPartitionator.PARTITION_ATTRIBUTE)) continue;
if (Integer.parseInt(u.getAttribute(GraphPartitionator.PARTITION_ATTRIBUTE)) == (partitionIndex)) {
intersection.add(u);
}
}
return intersection;
}
示例3: getIntersectionValue
import org.graphstream.graph.Node; //导入方法依赖的package包/类
public Integer getIntersectionValue(Node v, Integer partitionIndex) throws PartitionOutOfBoundException {
checkIndex(partitionIndex);
Iterator<Node> vNeigh = v.getNeighborNodeIterator();
int intersection = 0;
while (vNeigh.hasNext()) {
Node u = vNeigh.next();
if (!u.hasAttribute(GraphPartitionator.PARTITION_ATTRIBUTE)) continue;
if (Integer.parseInt(u.getAttribute(GraphPartitionator.PARTITION_ATTRIBUTE)) == (partitionIndex)) {
intersection ++;
}
}
return intersection;
}
示例4: cuvCalculator
import org.graphstream.graph.Node; //导入方法依赖的package包/类
public static List<Node> cuvCalculator(final Node u, Node v) {
List<Node> cuv = new ArrayList<>(u.getDegree());
Iterator<Node> uIterator = u.getNeighborNodeIterator();
while (uIterator.hasNext()) {
Node w = uIterator.next();
if (v.hasEdgeBetween(w)) {
cuv.add(w);
}
}
return cuv;
}
示例5: getNeigh
import org.graphstream.graph.Node; //导入方法依赖的package包/类
private String getNeigh(Node n) {
String nodeNString = "";
Iterator<Node> nn = n.getNeighborNodeIterator();
while (nn.hasNext()) {
nodeNString += " " + nn.next().getAttribute(NODE_ID);
}
return nodeNString;
}
示例6: getIndex
import org.graphstream.graph.Node; //导入方法依赖的package包/类
public Integer getIndex(PartitionMap partitionMap, Node n) {
Integer c = partitionMap.getC();
if (n.getDegree() == 0) {
return new BalancedHeuristic(parallel).getIndex(partitionMap, n);
}
Map<Integer, Double> partitionsScores = new ConcurrentHashMap<>(partitionMap.getK());
for (int i = 1; i <= partitionMap.getK(); i++) {
if(partitionMap.getPartition(i).size() >= c)
{
continue;
}
int y=0;
for (int j = 1; j <= partitionMap.getK(); j++) {
int tmp=partitionMap.getIntersectionValue(n,j);
if(j!=i) y+=tmp;
}
int x=partitionMap.getIntersectionValue(n, i);
int score=-x+y;//-partitionMap.getIntersectionValue(n, i);
Iterator<Node> pOFn=n.getNeighborNodeIterator();
Node p=null;
while(pOFn.hasNext())
{
p=pOFn.next();
if(!p.hasAttribute(GraphPartitionator.PARTITION_ATTRIBUTE))
score+=phiNeighbor(partitionMap, n, p, i);
}
partitionsScores.put(i, (double)score);
// System.out.println(n+" = "+partitionsScores);
}
if (partitionsScores.isEmpty()) {
return new BalancedHeuristic(parallel).getIndex(partitionMap, n);
}
Stream<Entry<Integer, Double>> strScore = partitionsScores.entrySet().stream();
if (parallel) {
strScore = strScore.parallel();
}
Integer maxPart = strScore
.min(new Comparator<Entry<Integer, Double>>() {
public int compare(Entry<Integer, Double> e1, Entry<Integer, Double> e2) {
Integer size1 = partitionMap.getPartitionSize(e1.getKey());
Integer size2 = partitionMap.getPartitionSize(e2.getKey());
Double score1 = getWeight((double)size1, c) *(e1.getValue());
Double score2 = getWeight((double)size2, c)*(e2.getValue());
if (score1 > score2) {
return 1;
} else if (score1 < score2) {
return -1;
} else {
return size1 >= size2 ? 1 : -1;
}
}
}).get().getKey();
return maxPart;
}
示例7: getIndex
import org.graphstream.graph.Node; //导入方法依赖的package包/类
public Integer getIndex(PartitionMap partitionMap, Node n) {
Double T=(double)++count/(double)(partitionMap.getC()*partitionMap.getK());
dist = new SimpleDistanceFunction();
Integer c = partitionMap.getC();
if (n.getDegree() == 0) {
return new BalancedHeuristic(parallel).getIndex(partitionMap, n);
}
//score for each neighbour
Map<Node, Double> nodeScores = new HashMap<Node, Double>(n.getDegree());
Iterator<Node> nNeighIt = n.getNeighborNodeIterator();
nNeighIt.forEachRemaining(p -> {
List<Node> cuv = Dispersion.cuvCalculator(n, p);
double emb=(double)cuv.size();
double disp=(double)Dispersion.getDispersion(n, p, dist,cuv);
double ndisp=emb==0?0:Math.min(1,disp/emb);
double beta=1-T;
nodeScores.put(p, T + beta*(1-ndisp));
});
Map<Integer, Double> partitionsScores = new ConcurrentHashMap<>(partitionMap.getK());
Stream<Entry<Node,Double>> nodeStream = nodeScores.entrySet().stream();
if (parallel) {
nodeStream = nodeStream.parallel();
}
nodeStream.filter(p -> p.getKey().hasAttribute(GraphPartitionator.PARTITION_ATTRIBUTE) &&
partitionMap.getPartitionSize(Integer.parseInt(p.getKey().getAttribute(GraphPartitionator.PARTITION_ATTRIBUTE))) < c)
.forEach(new Consumer<Entry<Node,Double>>() {
public void accept(Entry<Node, Double> t) {
Node v = t.getKey();
Integer partitionIndex = Integer.parseInt(v.getAttribute(GraphPartitionator.PARTITION_ATTRIBUTE));
if (partitionsScores.containsKey(partitionIndex)){
partitionsScores.put(partitionIndex,
((partitionsScores.get(partitionIndex)) + t.getValue()) );
} else {
partitionsScores.put(partitionIndex, (double) t.getValue());
}
}
});
if (partitionsScores.isEmpty()) {
return new BalancedHeuristic(parallel).getIndex(partitionMap, n);
}
Stream<Entry<Integer, Double>> strScore = partitionsScores.entrySet().stream();
if (parallel) {
strScore = strScore.parallel();
}
Integer maxPart = strScore
.max(new Comparator<Entry<Integer, Double>>() {
public int compare(Entry<Integer, Double> e1, Entry<Integer, Double> e2) {
Integer size1 = partitionMap.getPartitionSize(e1.getKey());
Integer size2 = partitionMap.getPartitionSize(e2.getKey());
Double score1 = getWeight((double)size1, c) *(e1.getValue());
Double score2 = getWeight((double)size2, c)*(e2.getValue());
if (score1 > score2) {
return 1;
} else if (score1 < score2) {
return -1;
} else {
return size1 >= size2 ? -1 : 1;
}
}
}).get().getKey();
return maxPart;
}
示例8: getIndex
import org.graphstream.graph.Node; //导入方法依赖的package包/类
public Integer getIndex(PartitionMap partitionMap, Node n) {
Integer c = partitionMap.getC();
if (n.getDegree() == 0) {
return new BalancedHeuristic(true).getIndex(partitionMap, n);
}
//score for each neighbour
Map<Node, Integer> nodeScores = new HashMap<Node, Integer>(n.getDegree());
Iterator<Node> nNeighIt = n.getNeighborNodeIterator();
Map<Node, Integer> nNeighNeigh = new ConcurrentHashMap<>();
//1 + disp(u,v) in order to mix DG with ADB
nNeighIt.forEachRemaining(p -> nodeScores.put(p, 1+ Dispersion.getDispersion(p, n, dist)));
nodeScores.keySet().parallelStream()
.forEach(p -> p.getNeighborNodeIterator()
.forEachRemaining(q -> nNeighNeigh.put(q, Dispersion.getDispersion(q, n, dist))));
Map<Integer, Double> partitionsScores = new ConcurrentHashMap<>(partitionMap.getK());
nodeScores.entrySet().parallelStream()
.filter(p -> p.getKey().hasAttribute(GraphPartitionator.PARTITION_ATTRIBUTE) &&
partitionMap.getPartitionSize(Integer.parseInt(p.getKey().getAttribute(GraphPartitionator.PARTITION_ATTRIBUTE))) <= c)
.forEach(new Consumer<Entry<Node,Integer>>() {
public void accept(Entry<Node, Integer> t) {
Node v = t.getKey();
Integer partitionIndex = Integer.parseInt(v.getAttribute(GraphPartitionator.PARTITION_ATTRIBUTE));
Integer partitionSize = partitionMap.getPartitionSize(partitionIndex);
if (partitionsScores.containsKey(partitionIndex)){
//x1*w+x2*w+...+xn*w = w*(x1+x2+..+xn)
partitionsScores.put(partitionIndex, (partitionsScores.get(partitionIndex)) + t.getValue()
* getWeight((double)partitionSize, c));
} else {
partitionsScores.put(partitionIndex, (double) t.getValue() *
getWeight((double) partitionSize, c));
}
}
});
if (partitionsScores.isEmpty()) {
return new BalancedHeuristic(true).getIndex(partitionMap, n);
}
Integer maxPart = partitionsScores.entrySet().parallelStream()
.max(new Comparator<Entry<Integer, Double>>() {
public int compare(Entry<Integer, Double> e1, Entry<Integer, Double> e2) {
Integer size1 = partitionMap.getPartitionSize(e1.getKey());
Integer size2 = partitionMap.getPartitionSize(e2.getKey());
Double score1 = e1.getValue();
Double score2 = e2.getValue();
if (Double.max(score1, score2) == score1) {
return 1;
} else if (Double.max(score1, score2) == score2) {
return -1;
} else { //inverse tie break
return size2 - size1;
}
}
}).get().getKey();
return maxPart;
}
开发者ID:isislab-unisa,项目名称:streaminggraphpartitioning,代码行数:64,代码来源:AbstractCompleteAbsDispersionBased.java
示例9: getIndexWithDispersionWithPredictionNeighbors
import org.graphstream.graph.Node; //导入方法依赖的package包/类
public final Integer getIndexWithDispersionWithPredictionNeighbors(PartitionMap partitionMap, Node n) {
Integer c = partitionMap.getC();
if (n.getDegree() == 0) {
return new BalancedHeuristic(parallel).getIndex(partitionMap, n);
}
Map<Integer, Double> partitionsScores = new ConcurrentHashMap<>(partitionMap.getK());
for (int i = 1; i <= partitionMap.getK(); i++) {
if(partitionMap.getPartition(i).size() >= c)
{
continue;
}
int y=0;
for (int j = 1; j <= partitionMap.getK(); j++) {
int tmp=partitionMap.getIntersectionValue(n,j);
if(j!=i) y+=tmp;
}
int x=partitionMap.getIntersectionValue(n, i);
int score=-x+y;//-partitionMap.getIntersectionValue(n, i);
Iterator<Node> pOFn=n.getNeighborNodeIterator();
Node p=null;
while(pOFn.hasNext())
{
p=pOFn.next();
if(!p.hasAttribute(GraphPartitionator.PARTITION_ATTRIBUTE))
score+=phiNeighbor(partitionMap, n, p, i);
}
partitionsScores.put(i, (double)score);
// System.out.println(n+" = "+partitionsScores);
}
if (partitionsScores.isEmpty()) {
return new BalancedHeuristic(parallel).getIndex(partitionMap, n);
}
Stream<Entry<Integer, Double>> strScore = partitionsScores.entrySet().stream();
if (parallel) {
strScore = strScore.parallel();
}
Integer maxPart = strScore
.min(new Comparator<Entry<Integer, Double>>() {
public int compare(Entry<Integer, Double> e1, Entry<Integer, Double> e2) {
// Integer intersection1 = partitionMap.getIntersectionValue(n, e1.getKey());
// Integer intersection2 = partitionMap.getIntersectionValue(n, e2.getKey());
Integer size1 = partitionMap.getPartitionSize(e1.getKey());
Integer size2 = partitionMap.getPartitionSize(e2.getKey());
//System.out.println("Score "+e1.getKey()+" "+e1.getValue());
Double score1 = getWeight((double)size1, c) *(e1.getValue());
Double score2 = getWeight((double)size2, c)*(e2.getValue());
if (score1 > score2) {
return 1;
} else if (score1 < score2) {
return -1;
} else {
return size1 >= size2 ? 1 : -1;
}
}
}).get().getKey();
// System.out.println(n+"->"+maxPart);
return maxPart;
}