@EVA001
2018-07-08T17:21:25.000000Z
字数 5472
阅读 829
未分类
在Source上施加引力
会导致中心聚集
在Target上施加引力
用每次加和的结果
斥力ok
引力ok
更新时的判断ok
dist>0 ok
html d3 要改 现在是正负500的矩形随机初始
每次整合后更新坐标,即加粗更新粒度(双向引力,类似单项引力)
*/ Map<String,Float> map = new HashMap<String,Float>();
for (Edge E : edges) {
// Idem, pour tous les noeuds on applique la force d'attraction
Node Source = E.getSource();
Node Target = E.getTarget();
float xDist = Source.x() - Target.x();
float yDist = Source.y() - Target.y();
// System.out.println(Source.x()+","+Source.y()+","+Target.x()+","+Target.y());
float dist = (float) Math.sqrt(xDist * xDist + yDist * yDist);
float attractiveF = dist * dist / k;
if (dist > 0) {
/*
ForceVectorNodeLayoutData sourceLayoutData = Source.getLayoutData();
sourceLayoutData.dx -= xDist / dist * attractiveF;
sourceLayoutData.dy -= yDist / dist * attractiveF;
ForceVectorNodeLayoutData targetLayoutData = Target.getLayoutData();
targetLayoutData.dx += xDist / dist * attractiveF;
targetLayoutData.dy += yDist / dist * attractiveF;
*/
//System.out.println("dx = "+(xDist / dist * attractiveF)+", dy = "+(yDist / dist * attractiveF));
if(map.containsKey(Source.getLabel())){
map.put(Source.getLabel()+'x', map.get(Source.getLabel()+'x') + xDist / dist * attractiveF);
map.put(Source.getLabel()+'y', map.get(Source.getLabel()+'y') + yDist / dist * attractiveF);
}else{
map.put(Source.getLabel()+'x', xDist / dist * attractiveF);
map.put(Source.getLabel()+'y', yDist / dist * attractiveF);
}
if(map.containsKey(Target.getLabel())){
map.put(Target.getLabel()+'x', map.get(Target.getLabel()+'x') + xDist / dist * attractiveF);
map.put(Target.getLabel()+'y', map.get(Target.getLabel()+'y') + yDist / dist * attractiveF);
}else{
map.put(Target.getLabel()+'x', xDist / dist * attractiveF);
map.put(Target.getLabel()+'y', yDist / dist * attractiveF);
}
}
}
for (Edge E : edges) {
Node Source = E.getSource();
ForceVectorNodeLayoutData sourceLayoutData = Source.getLayoutData();
sourceLayoutData.dx -= map.get(Source.getLabel()+'x');
sourceLayoutData.dy -= map.get(Source.getLabel()+'y');
Node Target = E.getTarget();
ForceVectorNodeLayoutData targetLayoutData = Target.getLayoutData();
targetLayoutData.dx += map.get(Target.getLabel()+'x');
targetLayoutData.dy += map.get(Target.getLabel()+'y');
}
引力双向全加 ok
引力斥力全加 860次迭代
引力斥力全加 200次迭代
400次 Vote
600次 Vote
800次 Vote
700 重力= 3
400 重力= 0
速度100 次数200 重力10
huyifan 默认
400 重力 10 速度 10
800 重力 3 速度 20
800 重力 3 速度 10
> Area : 10000
> Spring constant : 200.56236303005485
> Graph data and area were prepared sucessfully.
> Graph layout finished.
> Size of the graph : 2485 nodes, 16173 edges.
> DONE!
> Use Time: 847773ms
OpenOrd 默认 Wikitalk
FR 800 3 20 Wikitalk
FR 200 3 20 Wikitalk 100成型
huyifan 默认 Wikitalk
我的算法200次 无采样部分
> This iteration( 200 ) of computing layout zb has finished ...
> Area : 10000
> Spring constant : 118.54466952761743
> Graph data and area were prepared sucessfully.
> Graph layout finished.
> Size of the graph : 7115 nodes, 103689 edges.
> DONE!
> Use Time: 984507ms
800 次 豌豆形状 速度20 重力3 Vote.txt FR
800 次 豌豆形状 默认linlog下 Vote.txt FA2
0.1 370
0.3 370
0,6
0.9
1
斥力计算时 对每个点的(n-1)节点进行采样,结果并不好,会导致节点内聚,并且减弱引力也没有效果,即采样过低时,会导致整个结构过于紧密,斥力不全(由于采样使斥力大小少了很多)
Wiki-Vote 250次
次数:250.0 时间:635.027秒
次数:250.0 时间:59.45秒
wiki-vote.txt 800 20 3
> This iteration( 797 ) of computing layout zb has finished ...
> This iteration( 798 ) of computing layout zb has finished ...
> This iteration( 799 ) of computing layout zb has finished ...
> This iteration( 800 ) of computing layout zb has finished ...
> Area : 10000
> Spring constant : 118.54466952761743
> Graph data and area were prepared sucessfully.
> Graph layout finished.
> Size of the graph : 7115 nodes, 103689 edges.
> DONE!
> Use Time: 5052354ms
sourceLayoutData.dx -= xDist*yin * graph.getDegree(Nt) / dist * attractiveF;
sourceLayoutData.dy -= yDist*yin * graph.getDegree(Nt) / dist * attractiveF;
targetLayoutData.dx += xDist*yin * graph.getDegree(Nf) / dist * attractiveF;
targetLayoutData.dy += yDist*yin * graph.getDegree(Nf) / dist * attractiveF;
double dt = graph.getDegree(Nt) - graph.getDegree(Nf);
dt = Math.abs(dt);
if(dt==0) dt=1;
sourceLayoutData.dx -= xDist*yin * dt / dist * attractiveF;
sourceLayoutData.dy -= yDist*yin * dt / dist * attractiveF;
targetLayoutData.dx += xDist*yin * dt / dist * attractiveF;
targetLayoutData.dy += yDist*yin * dt / dist * attractiveF;
没重力
只有大节点的斥力
thisSet = 41 //// bignodes = 34 /// nodes = 327
thisSet = 35 //// bignodes = 34 /// nodes = 327
thisSet = 37 //// bignodes = 34 /// nodes = 327
thisSet = 252 //// bignodes = 34 /// nodes = 327
thisSet = 35 //// bignodes = 34 /// nodes = 327
邻居节点+大度的节点(球状缺失)
邻居节点+大度的节点+邻居节点的邻居节点(出球的关键)
for (Node N1 : nodes) {
graph.getNeighbors(N1);
//List<Node> thisSet = bignodes;
List<Node> thisSet = new ArrayList<Node>();
if(graph.getDegree(N1) > avgD){
//System.out.println("this is a big node.");
}else{
for (Node N2 : graph.getNeighbors(N1)) {
thisSet.add(N2);
for (Node N3 : graph.getNeighbors(N2)) {
thisSet.add(N3);
}
//System.out.println(avgD+" ... "+graph.getDegree(N2)+"xxxxx ="+thisSet.size());
}
}
for (int i=0;i<bignodes.size();i++) {
if(!thisSet.contains(bignodes.get(i)))
thisSet.add(bignodes.get(i));
}
//System.out.println("thisSet = "+thisSet.size()+" //// bignodes = "+bignodes.size()+" /// nodes = "+nodes.length);
for (int i=0;i<thisSet.size();i++) { // On fait toutes les paires de noeuds
Node N2 = thisSet.get(i);
if (N1 != N2) {
float xDist = N1.x() - N2.x(); // distance en x entre les deux noeuds
float yDist = N1.y() - N2.y();
float dist = (float) Math.sqrt(xDist * xDist + yDist * yDist) - N1.size() - N2.size();
ForceVectorNodeLayoutData layoutData1 = N1.getLayoutData();
ForceVectorNodeLayoutData layoutData2 = N2.getLayoutData();
if (dist > 0) {
float repulsiveF = k * k / dist; // Force de répulsion
double dt = graph.getDegree(N1) - graph.getDegree(N2);
dt = Math.abs(dt);
if(dt==0) dt=1; //如果不加,会导致相同度的点之间斥力缺失
layoutData1.dx += xDist*dt*chi / dist * repulsiveF; // on l'applique...
layoutData1.dy += yDist*dt*chi / dist * repulsiveF;
layoutData2.dx -= xDist*dt*chi / dist * repulsiveF; // on l'applique...
layoutData2.dy -= yDist*dt*chi / dist * repulsiveF;
}
}
}
}
200 次 3 20 1st
200 次 3 20 2nd
Area : 10000
Spring constant : 118.54466952761743
Graph data and area were prepared sucessfully.
Graph layout finished.
Size of the graph : 7115 nodes, 103689 edges.
DONE!
Use Time: 702522ms