org.gephi.graph.api.Graph.getNodeCount()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(174)

本文整理了Java中org.gephi.graph.api.Graph.getNodeCount()方法的一些代码示例,展示了Graph.getNodeCount()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.getNodeCount()方法的具体详情如下:
包路径:org.gephi.graph.api.Graph
类名称:Graph
方法名:getNodeCount

Graph.getNodeCount介绍

[英]Gets the number of nodes in the graph.
[中]获取图形中的节点数。

代码示例

代码示例来源:origin: org.gephi/filters-plugin

@Override
public boolean init(Graph graph) {
  return graph.getNodeCount() != 0;
}

代码示例来源:origin: org.gephi/statistics-plugin

public void initStartValues(Graph graph) {
  N = graph.getNodeCount();
  K = (int) Math.sqrt(N);
  nodeClustering = new double[N];
  network = new ArrayWrapper[N];
  triangles = new int[N];
}

代码示例来源:origin: org.gephi/statistics-plugin

private double updateValues(Graph graph, double[] tempValues, double[] centralityValues, double max) {
  double sumChanged = 0.;
  int N = graph.getNodeCount();
  for (int k = 0; k < N; k++) {
    if (max != 0) {
      sumChanged += Math.abs(centralityValues[k] - (tempValues[k] / max));
      centralityValues[k] = tempValues[k] / max;
    } else {
      centralityValues[k] = 0.0;
    }
    if (isCanceled) {
      return sumChanged;
    }
  }
  return sumChanged;
}

代码示例来源:origin: org.gephi/statistics-plugin

private void saveCalculatedValues(Graph graph, Column attributeColumn, HashMap<Integer, Node> indicies,
    double[] eigCenrtalities) {
  int N = graph.getNodeCount();
  for (int i = 0; i < N; i++) {
    Node s = indicies.get(i);
    s.setAttribute(attributeColumn, eigCenrtalities[i]);
  }
}

代码示例来源:origin: org.gephi/statistics-plugin

private void calculateCorrection(Graph graph, HashMap<Node, Integer> indicies,
    double[] nodeBetweenness, boolean directed, boolean normalized) {
  int n = graph.getNodeCount();
  for (Node s : graph.getNodes()) {
    int s_index = indicies.get(s);
    if (!directed) {
      nodeBetweenness[s_index] /= 2;
    }
    if (normalized) {
      nodeBetweenness[s_index] /= directed ? (n - 1) * (n - 2) : (n - 1) * (n - 2) / 2;
    }
  }
}

代码示例来源:origin: org.gephi/statistics-plugin

public double calculateDensity(Graph graph, boolean isGraphDirected) {
  double result;
  double edgesCount = graph.getEdgeCount();
  double nodesCount = graph.getNodeCount();
  double multiplier = 1;
  if (!isGraphDirected) {
    multiplier = 2;
  }
  result = (multiplier * edgesCount) / (nodesCount * nodesCount - nodesCount);
  return result;
}

代码示例来源:origin: org.gephi/filters-plugin

@Override
public boolean init(Graph graph) {
  return !(graph.getNodeCount() == 0 || !(graph.isDirected()));
}

代码示例来源:origin: org.gephi/filters-plugin

@Override
public boolean init(Graph graph) {
  return !(graph.getNodeCount() == 0 || !(graph.isDirected()));
}

代码示例来源:origin: org.gephi/datalab-api

@Override
public int getNodesCount() {
  Graph graph = getCurrentGraph();
  return graph.getNodeCount();
}

代码示例来源:origin: org.gephi/filters-plugin

@Override
public boolean init(Graph graph) {
  return !(graph.getNodeCount() == 0 || !(graph.isDirected()));
}

代码示例来源:origin: org.gephi/filters-plugin

@Override
public Number[] getValues(Graph graph) {
  List<Integer> values = new ArrayList<>(graph.getNodeCount());
  for (Node n : graph.getNodes()) {
    int degree = graph.getDegree(n);
    values.add(degree);
  }
  return values.toArray(new Number[0]);
}

代码示例来源:origin: org.gephi/appearance-api

@Override
  protected void refresh() {
    if (graph.getNodeCount() > 0) {
      int minV = Integer.MAX_VALUE;
      int maxV = Integer.MIN_VALUE;
      for (Node n : graph.getNodes()) {
        int degree = graph.getDegree(n);
        minV = Math.min(degree, minV);
        maxV = Math.max(degree, maxV);
      }
      min = minV;
      max = maxV;
    }
  }
}

代码示例来源:origin: org.gephi/statistics-plugin

public void execute(Graph graph) {
  isCanceled = false;
  graph.readLock();
  try {
    structure = new Modularity.CommunityStructure(graph);
    int[] comStructure = new int[graph.getNodeCount()];
    if (graph.getNodeCount() > 0) {//Fixes issue #713 Modularity Calculation Throws Exception On Empty Graph
      HashMap<String, Double> computedModularityMetrics = computeModularity(graph, structure, comStructure, resolution, isRandomized, useWeight);
      modularity = computedModularityMetrics.get("modularity");
      modularityResolution = computedModularityMetrics.get("modularityResolution");
    } else {
      modularity = 0;
      modularityResolution = 0;
    }
    saveValues(comStructure, graph, structure);
  } finally {
    graph.readUnlock();
  }
}

代码示例来源:origin: org.gephi/filters-plugin

@Override
public boolean init(Graph graph) {
  if (AttributeUtils.isNodeColumn(column)) {
    if (graph.getNodeCount() == 0) {
      return false;
    }
  } else if (AttributeUtils.isEdgeColumn(column)) {
    if (graph.getEdgeCount() == 0) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: org.gephi/filters-plugin

@Override
public boolean init(Graph graph) {
  if (AttributeUtils.isNodeColumn(column)) {
    if (graph.getNodeCount() == 0) {
      return false;
    }
  } else if (AttributeUtils.isEdgeColumn(column)) {
    if (graph.getEdgeCount() == 0) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: org.gephi/filters-plugin

@Override
public boolean init(Graph graph) {
  if (AttributeUtils.isNodeColumn(column)) {
    if (graph.getNodeCount() == 0) {
      return false;
    }
  } else if (AttributeUtils.isEdgeColumn(column)) {
    if (graph.getEdgeCount() == 0) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: org.gephi/statistics-plugin

public double calculateEigenvectorCentrality(Graph graph, double[] eigCentralities,
    HashMap<Integer, Node> indicies, HashMap<Node, Integer> invIndicies,
    boolean directed, int numIterations) {
  int N = graph.getNodeCount();
  double sumChanged = 0.;
  double[] tmp = new double[N];
  for (int s = 0; s < numIterations; s++) {
    double max = computeMaxValueAndTempValues(graph, indicies, invIndicies, tmp, eigCentralities, directed);
    sumChanged = updateValues(graph, tmp, eigCentralities, max);
    if (isCanceled) {
      return sumChanged;
    }
    Progress.progress(progress);
  }
  return sumChanged;
}

代码示例来源:origin: org.gephi/statistics-plugin

@Override
public void loop(GraphView window, Interval interval) {
  Graph graph = graphModel.getGraph(window);
  int count = graph.getNodeCount();
  graphModel.getGraphVisible().setAttribute(NB_NODES, count, interval.getLow());
  graphModel.getGraphVisible().setAttribute(NB_NODES, count, interval.getHigh());
  counts.put(interval.getLow(), count);
  counts.put(interval.getHigh(), count);
}

代码示例来源:origin: org.gephi/statistics-plugin

public void execute(Graph graph) {
  initializeAttributeColunms(graph.getModel());
  graph.readLock();
  try {
    int N = graph.getNodeCount();
    authority = new double[N];
    hubs = new double[N];
    Map<Node, Integer> indices = createIndicesMap(graph);
    calculateHits(graph, hubs, authority, indices, !useUndirected, epsilon);
    saveCalculatedValues(indices, authority, hubs);
  } finally {
    graph.readUnlockAll();
  }
}

代码示例来源:origin: org.gephi/preview-plugin

@Override
public Item[] getItems(Graph graph) {
  Item[] items = new NodeItem[graph.getNodeCount()];
  int i = 0;
  for (Node n : graph.getNodes()) {
    NodeItem nodeItem = new NodeItem(n);
    nodeItem.setData(NodeItem.X, n.x());
    nodeItem.setData(NodeItem.Y, -n.y());
    nodeItem.setData(NodeItem.Z, n.z());
    nodeItem.setData(NodeItem.SIZE, n.size() * 2f);
    nodeItem.setData(NodeItem.COLOR, n.getColor());
    items[i++] = nodeItem;
  }
  return items;
}

相关文章