コード例 #1
0
  public void initAlgo() {
    graph = graphModel.getHierarchicalGraphVisible();
    initedView = graph.getView().getViewId();
    setConverged(false);
    level = 0;

    while (true) {
      int graphSize = graph.getTopNodes().toArray().length;
      coarseningStrategy.coarsen(graph);
      level++;
      int newGraphSize = graph.getTopNodes().toArray().length;
      if (newGraphSize < getMinSize() || newGraphSize > graphSize * getMinCoarseningRate()) {
        break;
      }
    }

    Layout random = new RandomLayout(1000);
    random.setGraphModel(graphModel);
    random.initAlgo();
    random.goAlgo();

    initYifanHu();
  }
コード例 #2
0
  public void refine(HierarchicalGraph graph) {
    double r = 10;
    int count = 0;
    int refined = 0;
    for (Node node : graph.getTopNodes().toArray()) {
      count++;
      if (graph.getChildrenCount(node) == 2) {
        refined++;
        float x = node.getNodeData().x();
        float y = node.getNodeData().y();

        for (Node child : graph.getChildren(node)) {
          double t = Math.random();
          child.getNodeData().setX((float) (x + r * Math.cos(t)));
          child.getNodeData().setY((float) (y + r * Math.sin(t)));
        }
        graph.ungroupNodes(node);
      }
    }
    // System.out.println("COUNT = " + count);
    // System.out.println("REFINED = " + refined);
  }