示例#1
0
  private void InitializeClusterGraphLayout() {
    int numClusters = myGraph.GetNumberOfClusters();
    double radius = Math.min(layout_width, layout_height) / 3.5;
    double angleShift = (2 * Math.PI) / numClusters;

    List<Functionality.Node> ln = myGraph.getNodes();

    Node n;
    int clusterID;
    for (int i = 0; i < ln.size(); i++) {
      n = ln.get(i);
      clusterID = n.GetCluster();

      if (clusterID == -1) continue;

      double xnew =
          (layout_width / 2)
              + Math.cos(angleShift * clusterID) * radius
              + (50 - Math.random() * 100);
      double ynew =
          (layout_height / 2)
              + Math.sin(angleShift * clusterID) * radius
              + (50 - Math.random() * 100);

      layout.setLocation(n, xnew, ynew);
    }
  }
示例#2
0
  private static Set<Functionality.Node> getNodesInDistance(
      Functionality.Node focusNode, int maxDistance, EdgeTypeEnum coreEdgeType) {
    Set<Functionality.Node> visitedNodes = new HashSet<Functionality.Node>();
    visitedNodes.add(focusNode);

    Set<Functionality.Node> retNodes = new HashSet<Functionality.Node>();
    retNodes.add(focusNode);

    List<Functionality.Node> proceedNodes = new ArrayList<Functionality.Node>();
    List<Integer> proceedDist = new ArrayList<Integer>();

    int nodePointer = 0;
    Node currNode;
    proceedNodes.add(focusNode);
    proceedDist.add(0);

    while (nodePointer < proceedNodes.size() && proceedDist.get(nodePointer) <= maxDistance - 1) {
      currNode = proceedNodes.get(nodePointer);
      for (Iterator<Node> it = currNode.getNeighbors().iterator(); it.hasNext(); ) {
        Node neib = it.next();

        if (coreEdgeType == EdgeTypeEnum.normal
                && DataModule.displayedGraph.edgeIsDotted(currNode, neib)
            || coreEdgeType == EdgeTypeEnum.thick
                && (DataModule.displayedGraph.edgeIsDotted(currNode, neib)
                    || DataModule.displayedGraph.edgeIsNormal(currNode, neib))) {
          continue;
        }

        if (visitedNodes.contains(neib) == false) {
          visitedNodes.add(neib);
          proceedDist.add(proceedDist.get(nodePointer) + 1);
          proceedNodes.add(neib);
        }
      }
      nodePointer++;
    }

    return visitedNodes;
  }