[关闭]
@EVA001 2018-07-08T17:21:25.000000Z 字数 5472 阅读 829

XXXXXXXXXXXXX 实验

未分类



在Source上施加引力
会导致中心聚集


在Target上施加引力


用每次加和的结果
斥力ok
引力ok
更新时的判断ok
dist>0 ok
html d3 要改 现在是正负500的矩形随机初始


每次整合后更新坐标,即加粗更新粒度(双向引力,类似单项引力)

  1. */ Map<String,Float> map = new HashMap<String,Float>();
  2. for (Edge E : edges) {
  3. // Idem, pour tous les noeuds on applique la force d'attraction
  4. Node Source = E.getSource();
  5. Node Target = E.getTarget();
  6. float xDist = Source.x() - Target.x();
  7. float yDist = Source.y() - Target.y();
  8. // System.out.println(Source.x()+","+Source.y()+","+Target.x()+","+Target.y());
  9. float dist = (float) Math.sqrt(xDist * xDist + yDist * yDist);
  10. float attractiveF = dist * dist / k;
  11. if (dist > 0) {
  12. /*
  13. ForceVectorNodeLayoutData sourceLayoutData = Source.getLayoutData();
  14. sourceLayoutData.dx -= xDist / dist * attractiveF;
  15. sourceLayoutData.dy -= yDist / dist * attractiveF;
  16. ForceVectorNodeLayoutData targetLayoutData = Target.getLayoutData();
  17. targetLayoutData.dx += xDist / dist * attractiveF;
  18. targetLayoutData.dy += yDist / dist * attractiveF;
  19. */
  20. //System.out.println("dx = "+(xDist / dist * attractiveF)+", dy = "+(yDist / dist * attractiveF));
  21. if(map.containsKey(Source.getLabel())){
  22. map.put(Source.getLabel()+'x', map.get(Source.getLabel()+'x') + xDist / dist * attractiveF);
  23. map.put(Source.getLabel()+'y', map.get(Source.getLabel()+'y') + yDist / dist * attractiveF);
  24. }else{
  25. map.put(Source.getLabel()+'x', xDist / dist * attractiveF);
  26. map.put(Source.getLabel()+'y', yDist / dist * attractiveF);
  27. }
  28. if(map.containsKey(Target.getLabel())){
  29. map.put(Target.getLabel()+'x', map.get(Target.getLabel()+'x') + xDist / dist * attractiveF);
  30. map.put(Target.getLabel()+'y', map.get(Target.getLabel()+'y') + yDist / dist * attractiveF);
  31. }else{
  32. map.put(Target.getLabel()+'x', xDist / dist * attractiveF);
  33. map.put(Target.getLabel()+'y', yDist / dist * attractiveF);
  34. }
  35. }
  36. }
  37. for (Edge E : edges) {
  38. Node Source = E.getSource();
  39. ForceVectorNodeLayoutData sourceLayoutData = Source.getLayoutData();
  40. sourceLayoutData.dx -= map.get(Source.getLabel()+'x');
  41. sourceLayoutData.dy -= map.get(Source.getLabel()+'y');
  42. Node Target = E.getTarget();
  43. ForceVectorNodeLayoutData targetLayoutData = Target.getLayoutData();
  44. targetLayoutData.dx += map.get(Target.getLabel()+'x');
  45. targetLayoutData.dy += map.get(Target.getLabel()+'y');
  46. }

引力双向全加 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

  1. > Area : 10000
  2. > Spring constant : 200.56236303005485
  3. > Graph data and area were prepared sucessfully.
  4. > Graph layout finished.
  5. > Size of the graph : 2485 nodes, 16173 edges.
  6. > DONE!
  7. > Use Time: 847773ms


OpenOrd 默认 Wikitalk


FR 800 3 20 Wikitalk

FR 200 3 20 Wikitalk 100成型

huyifan 默认 Wikitalk


我的算法200次 无采样部分

  1. > This iteration( 200 ) of computing layout zb has finished ...
  2. > Area : 10000
  3. > Spring constant : 118.54466952761743
  4. > Graph data and area were prepared sucessfully.
  5. > Graph layout finished.
  6. > Size of the graph : 7115 nodes, 103689 edges.
  7. > DONE!
  8. > 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秒

  1. wiki-vote.txt 800 20 3
  2. > This iteration( 797 ) of computing layout zb has finished ...
  3. > This iteration( 798 ) of computing layout zb has finished ...
  4. > This iteration( 799 ) of computing layout zb has finished ...
  5. > This iteration( 800 ) of computing layout zb has finished ...
  6. > Area : 10000
  7. > Spring constant : 118.54466952761743
  8. > Graph data and area were prepared sucessfully.
  9. > Graph layout finished.
  10. > Size of the graph : 7115 nodes, 103689 edges.
  11. > DONE!
  12. > Use Time: 5052354ms

  1. sourceLayoutData.dx -= xDist*yin * graph.getDegree(Nt) / dist * attractiveF;
  2. sourceLayoutData.dy -= yDist*yin * graph.getDegree(Nt) / dist * attractiveF;
  3. targetLayoutData.dx += xDist*yin * graph.getDegree(Nf) / dist * attractiveF;
  4. targetLayoutData.dy += yDist*yin * graph.getDegree(Nf) / dist * attractiveF;

  1. double dt = graph.getDegree(Nt) - graph.getDegree(Nf);
  2. dt = Math.abs(dt);
  3. if(dt==0) dt=1;
  4. sourceLayoutData.dx -= xDist*yin * dt / dist * attractiveF;
  5. sourceLayoutData.dy -= yDist*yin * dt / dist * attractiveF;
  6. targetLayoutData.dx += xDist*yin * dt / dist * attractiveF;
  7. targetLayoutData.dy += yDist*yin * dt / dist * attractiveF;

没重力

只有大节点的斥力

  1. thisSet = 41 //// bignodes = 34 /// nodes = 327
  2. thisSet = 35 //// bignodes = 34 /// nodes = 327
  3. thisSet = 37 //// bignodes = 34 /// nodes = 327
  4. thisSet = 252 //// bignodes = 34 /// nodes = 327
  5. thisSet = 35 //// bignodes = 34 /// nodes = 327

邻居节点+大度的节点(球状缺失)

邻居节点+大度的节点+邻居节点的邻居节点(出球的关键)

  1. for (Node N1 : nodes) {
  2. graph.getNeighbors(N1);
  3. //List<Node> thisSet = bignodes;
  4. List<Node> thisSet = new ArrayList<Node>();
  5. if(graph.getDegree(N1) > avgD){
  6. //System.out.println("this is a big node.");
  7. }else{
  8. for (Node N2 : graph.getNeighbors(N1)) {
  9. thisSet.add(N2);
  10. for (Node N3 : graph.getNeighbors(N2)) {
  11. thisSet.add(N3);
  12. }
  13. //System.out.println(avgD+" ... "+graph.getDegree(N2)+"xxxxx ="+thisSet.size());
  14. }
  15. }
  16. for (int i=0;i<bignodes.size();i++) {
  17. if(!thisSet.contains(bignodes.get(i)))
  18. thisSet.add(bignodes.get(i));
  19. }
  20. //System.out.println("thisSet = "+thisSet.size()+" //// bignodes = "+bignodes.size()+" /// nodes = "+nodes.length);
  21. for (int i=0;i<thisSet.size();i++) { // On fait toutes les paires de noeuds
  22. Node N2 = thisSet.get(i);
  23. if (N1 != N2) {
  24. float xDist = N1.x() - N2.x(); // distance en x entre les deux noeuds
  25. float yDist = N1.y() - N2.y();
  26. float dist = (float) Math.sqrt(xDist * xDist + yDist * yDist) - N1.size() - N2.size();
  27. ForceVectorNodeLayoutData layoutData1 = N1.getLayoutData();
  28. ForceVectorNodeLayoutData layoutData2 = N2.getLayoutData();
  29. if (dist > 0) {
  30. float repulsiveF = k * k / dist; // Force de répulsion
  31. double dt = graph.getDegree(N1) - graph.getDegree(N2);
  32. dt = Math.abs(dt);
  33. if(dt==0) dt=1; //如果不加,会导致相同度的点之间斥力缺失
  34. layoutData1.dx += xDist*dt*chi / dist * repulsiveF; // on l'applique...
  35. layoutData1.dy += yDist*dt*chi / dist * repulsiveF;
  36. layoutData2.dx -= xDist*dt*chi / dist * repulsiveF; // on l'applique...
  37. layoutData2.dy -= yDist*dt*chi / dist * repulsiveF;
  38. }
  39. }
  40. }
  41. }



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

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注