Codota Logo
NodeIterable.toArray
Code IndexAdd Codota to your IDE (free)

How to use
toArray
method
in
org.gephi.graph.api.NodeIterable

Best Java code snippets using org.gephi.graph.api.NodeIterable.toArray (Showing top 20 results out of 315)

  • Common ways to obtain NodeIterable
private void myMethod () {
NodeIterable n =
  • Codota IconGraph graph;graph.getNodes()
  • Codota IconGraph graph;Node node;graph.getNeighbors(node)
  • Smart code suggestions by Codota
}
origin: gephi/gephi-plugins-bootcamp

@Override
public boolean init(Graph graph) {
  Node[] nodes = graph.getNodes().toArray();
  Arrays.sort(nodes, new Comparator<Node>() {
    @Override
    public int compare(Node o1, Node o2) {
      Comparable a1 = (Comparable) o1.getAttribute(column);
      Comparable a2 = (Comparable) o2.getAttribute(column);
      if (a1 == null && a2 != null) {
        return 1;
      } else if (a1 != null && a2 == null) {
        return -1;
      } else if (a1 == null && a2 == null) {
        return 0;
      } else {
        return a2.compareTo(a1);
      }
    }
  });
  topSet = new HashSet<Node>(top);
  for (int i = 0; i < top && i < nodes.length; i++) {
    topSet.add(nodes[i]);
  }
  return true;
}
origin: org.gephi/datalab-api

/**
 * Used for iterating through all nodes of the graph
 *
 * @return Array with all graph nodes
 */
private Node[] getNodesArray() {
  return Lookup.getDefault().lookup(GraphController.class).getGraphModel().getGraph().getNodes().toArray();
}
origin: org.gephi/datalab-api

@Override
public Node[] getNodeNeighbours(Node node) {
  return getCurrentGraph().getNeighbors(node).toArray();
}
origin: org.gephi/datalab-api

/**
 * Sets nodesToSearch as all nodes in the graph if they are null or empty array.
 * Also only search on visible view if data table is showing visible only.
 */
private void checkNodesToSearch() {
  if (nodesToSearch == null || nodesToSearch.length == 0) {
    Graph graph;
    if (Lookup.getDefault().lookup(DataTablesController.class).isShowOnlyVisible()) {
      graph = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getGraphVisible();
    } else {
      graph = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getGraph();
    }
    nodesToSearch = graph.getNodes().toArray();
  }
}
origin: org.gephi/filters-plugin

for (Node node : graph.getNodes().toArray()) {
  if (!result.contains(node)) {
    graph.removeNode(node);
origin: org.gephi/datalab-api

DateTimeZone timeZone = graph.getModel().getTimeZone();
for (Node node : graph.getNodes().toArray()) {
  value = node.getAttribute(column);
  if (value != null) {
origin: org.gephi/filters-plugin

@Override
public Graph filter(Graph graph) {
  int removed = 0;
  do {
    removed = 0;
    for (Node n : graph.getNodes().toArray()) {
      if (graph.getDegree(n) < k) {
        graph.removeNode(n);
        removed++;
      }
    }
  } while (removed > 0);
  return graph;
}
origin: gephi/gephi-plugins-bootcamp

@Override
public void execute() {
  //Note that a function to inverse selection directly in the table with DataTablesController
  //would be more efficient than calculating it here, but this example demonstrates some table selection features.
  DataTablesController dtc = Lookup.getDefault().lookup(DataTablesController.class);
  Graph graph = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getGraph();
  if (dtc.isNodeTableMode()) {
    //Get currently selected nodes and calculate inverse set.
    Node[] selected = dtc.getNodeTableSelection();
    ArrayList<Node> nodes = new ArrayList<Node>();
    nodes.addAll(Arrays.asList(graph.getNodes().toArray()));
    for (Node node : selected) {
      nodes.remove(node);
    }
    dtc.setNodeTableSelection(nodes.toArray(new Node[0]));
  } else if (dtc.isEdgeTableMode()) {
    //Get currently selected edges and calculate inverse set.
    Edge[] selected = dtc.getEdgeTableSelection();
    ArrayList<Edge> edges = new ArrayList<Edge>();
    edges.addAll(Arrays.asList(graph.getEdges().toArray()));
    for (Edge edge : selected) {
      edges.remove(edge);
    }
    dtc.setEdgeTableSelection(edges.toArray(new Edge[0]));
  }
}
origin: gephi/gephi-plugins-bootcamp

@Override
public void goAlgo() {
  Graph graph = graphModel.getGraphVisible();
  graph.readLock();
  int nodeCount = graph.getNodeCount();
  Node[] nodes = graph.getNodes().toArray();
  int rows = (int) Math.round(Math.sqrt(nodeCount)) + 1;
  int cols = (int) Math.round(Math.sqrt(nodeCount)) + 1;
  for (int i = 0; i < rows; i++) {
    for (int j = 0; j < cols && (i * rows + j) < nodes.length; j++) {
      Node node = nodes[i * rows + j];
      float x = (-areaSize / 2f) + ((float) j / cols) * areaSize;
      float y = (areaSize / 2f) - ((float) i / rows) * areaSize;
      float px = node.x();
      float py = node.y();
      node.setX(px + (x - px) * (speed / 10000f));
      node.setY(py + (y - py) * (speed / 10000f));
    }
  }
  graph.readUnlock();
}
origin: org.gephi/datalab-plugin

if (onlyVisibleElements) {
  nodes = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getGraphVisible().getNodes().toArray();
} else {
  nodes = new Node[0];//Search on all nodes
origin: org.gephi/datalab-plugin

@Override
public void setup(Manipulator m, DialogControls dialogControls) {
  this.manipulator = (AddEdgeToGraph) m;
  if (manipulator.isDirected()) {
    directedRadioButton.setSelected(true);
  } else {
    undirectedRadioButton.setSelected(true);
  }
  graph = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getGraph();
  nodes = graph.getNodes().toArray();
  workspace = Lookup.getDefault().lookup(ProjectController.class).getCurrentWorkspace();
  for (Node n : nodes) {
    sourceNodesComboBox.addItem(n.getId() + " - " + n.getLabel());
    targetNodesComboBox.addItem(n.getId() + " - " + n.getLabel());
  }
  SelectedOptions selectedOptions = workspace.getLookup().lookup(SelectedOptions.class);
  if (selectedOptions != null) {
    setNodeComboBoxSelection(sourceNodesComboBox, selectedOptions.source);
    setNodeComboBoxSelection(targetNodesComboBox, selectedOptions.target);
    edgeTypeComboBox.setSelectedItem(selectedOptions.edgeType);
  } else {
    workspace.add(new SelectedOptions());
  }
  refreshAvailableEdgeTypes();
  dialogControls.setOkButtonEnabled(nodes.length > 0);
}
origin: org.gephi/desktop-datalab

nodeTable.refreshModel(graph.getNodes().toArray(), cols, graphModel, dataTablesModel);
origin: gephi/gephi-plugins-bootcamp

graph.readLock();
int nodeCount = graph.getNodeCount();
Node[] nodes = graph.getNodes().toArray();
origin: org.gephi/visualization

  @Override
  public void actionPerformed(ActionEvent evt) {
    GraphController gc = Lookup.getDefault().lookup(GraphController.class);
    GraphModel gm = gc.getGraphModel();
    Graph graph = gm.getGraphVisible();
    for (Node n : graph.getNodes().toArray()) {
      n.getTextProperties().setColor(Color.BLACK);
      n.getTextProperties().setAlpha(0f);
    }
    for (Edge e : graph.getEdges().toArray()) {
      e.getTextProperties().setColor(Color.BLACK);
      e.getTextProperties().setAlpha(0f);
    }
  }
});
origin: org.gephi/layout-plugin

@Override
public void initAlgo() {
  AbstractLayout.ensureSafeLayoutNodePositions(graphModel);
  
  speed = 1.;
  speedEfficiency = 1.;
  graph = graphModel.getGraphVisible();
  graph.readLock();
  try {
    Node[] nodes = graph.getNodes().toArray();
    // Initialise layout data
    for (Node n : nodes) {
      if (n.getLayoutData() == null || !(n.getLayoutData() instanceof ForceAtlas2LayoutData)) {
        ForceAtlas2LayoutData nLayout = new ForceAtlas2LayoutData();
        n.setLayoutData(nLayout);
      }
      ForceAtlas2LayoutData nLayout = n.getLayoutData();
      nLayout.mass = 1 + graph.getDegree(n);
      nLayout.old_dx = 0;
      nLayout.old_dy = 0;
      nLayout.dx = 0;
      nLayout.dy = 0;
    }
    pool = Executors.newFixedThreadPool(threadCount);
    currentThreadCount = threadCount;
  } finally {
    graph.readUnlockAll();
  }
}

origin: gephi/gephi-toolkit-demos

  Node[] neighbors = directedGraph.getNeighbors(n).toArray();
  System.out.println(n.getLabel() + " has " + neighbors.length + " neighbors");
for (Node n : directedGraph.getNodes().toArray()) {
  directedGraph.removeNode(n);
origin: gephi/gephi-plugins-bootcamp

Node[] nodes = graph.getNodes().toArray();
for (Node n : nodes) {
  double avg = 0;
origin: org.gephi/preview-api

GraphView reducedView = graphModel.copyView(graph.getView());
graph = graphModel.getGraph(reducedView);
Node[] nodes = graph.getNodes().toArray();
for (int i = 0; i < nodes.length; i++) {
  float r = (float) i / (float) nodes.length;
origin: org.gephi/filters-plugin

@Override
public Graph filter(Subgraph[] graphs) {
  if (graphs.length > 1) {
    throw new IllegalArgumentException("Not Filter accepts a single graph in parameter");
  }
  Graph graph = graphs[0];
  Graph mainGraph = graph.getView().getGraphModel().getGraph();
  for (Node n : mainGraph.getNodes().toArray()) {
    if (!graph.contains(n)) {
      //The node n is not in graph
      graph.addNode(n);
    } else {
      //The node n is in graph
      graph.removeNode(n);
    }
  }
  for (Edge e : mainGraph.getEdges()) {
    Node source = e.getSource();
    Node target = e.getTarget();
    if (graph.contains(source) && graph.contains(target)) {
      Edge edgeInGraph = graph.getEdge(source, target, e.getType());
      if (edgeInGraph == null) {
        graph.addEdge(e);
      }
    }
  }
  return graph;
}
origin: org.gephi/statistics-plugin

for (Node n : graph.getNodes().toArray()) {
  int degree = graph.getDegree(n);
org.gephi.graph.apiNodeIterabletoArray

Javadoc

Returns the iterator content as an array.

Popular methods of NodeIterable

  • toCollection
    Returns the iterator content as a collection.
  • doBreak
  • iterator
    Returns a node iterator.

Popular in Java

  • Updating database using SQL prepared statement
  • setContentView (Activity)
  • getSharedPreferences (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • KeyStore (java.security)
    This class represents an in-memory collection of keys and certificates. It manages two types of entr
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Iterator (java.util)
    An iterator over a collection. Iterator takes the place of Enumeration in the Java Collections Frame
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Logger (org.slf4j)
    The main user interface to logging. It is expected that logging takes place through concrete impleme
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now