Tabnine Logo
NodeIterable
Code IndexAdd Tabnine to your IDE (free)

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

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

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/statistics-plugin

index++;
if (isCanceled) {
  nodesIterable.doBreak();
  return;
topology[node_index] = new ArrayList<>();
Set<Node> uniqueNeighbors = new HashSet<>(graph.getNeighbors(node).toCollection());
for (Node neighbor : uniqueNeighbors) {
  if (node == neighbor) {
  nodesIterable.doBreak();
  return;
origin: org.gephi/graphstore

public void indexView(Graph graph) {
  TimeIndexImpl viewIndex = viewIndexes.get(graph.getView());
  if (viewIndex != null) {
    graph.readLock();
    try {
      Iterator<T> iterator = null;
      if (elementType.equals(Node.class)) {
        iterator = (Iterator<T>) graph.getNodes().iterator();
      } else if (elementType.equals(Edge.class)) {
        iterator = (Iterator<T>) graph.getEdges().iterator();
      }
      if (iterator != null) {
        while (iterator.hasNext()) {
          Element element = iterator.next();
          S set = getTimeSet(element);
          if (set != null) {
            K[] ts = set.toArray();
            int tsLength = ts.length;
            for (int i = 0; i < tsLength; i++) {
              int timestamp = timeSortedMap.get(ts[i]);
              viewIndex.add(timestamp, element);
            }
          }
        }
      }
    } finally {
      graph.readUnlock();
    }
  }
}
origin: org.gephi/statistics-plugin

if (index[indices.get(u)] == 0) {
  first = u;
  iter.doBreak();
  break;
origin: org.gephi/tools-plugin

public static Node[] getPredecessors(DirectedGraph graph, Node[] nodes) {
  Set<Node> nodeTree = new HashSet<>();
  graph.readLock();
  try {
    for (Node n : nodes) {
      nodeTree.addAll(graph.getPredecessors(n).toCollection());
    }
  } finally {
    graph.readUnlock();
  }
  //remove original nodes
  for (Node n : nodes) {
    nodeTree.remove(n);
  }
  return nodeTree.toArray(new Node[0]);
}
origin: org.gephi/statistics-plugin

if (color[indices.get(next)] == 0) {
  Q.add(next);
  iter.doBreak();
  break;
origin: org.gephi/tools-plugin

public static Node[] getNeighbors(Graph graph, Node[] nodes) {
  Set<Node> nodeTree = new HashSet<>();
  
  graph.readLock();
  try {
    for (Node n : nodes) {
      nodeTree.addAll(graph.getNeighbors(n).toCollection());
    }
  } finally {
    graph.readUnlock();
  }
  //remove original nodes
  for (Node n : nodes) {
    nodeTree.remove(n);
  }
  return nodeTree.toArray(new Node[0]);
}
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/statistics-plugin

nodesIterable.doBreak();
return metrics;
origin: org.gephi/tools-plugin

public static Node[] getSuccessors(DirectedGraph graph, Node[] nodes) {
  Set<Node> nodeTree = new HashSet<>();
  graph.readLock();
  try {
    for (Node n : nodes) {
      nodeTree.addAll(graph.getSuccessors(n).toCollection());
    }
  } finally {
    graph.readUnlock();
  }
  //remove original nodes
  for (Node n : nodes) {
    nodeTree.remove(n);
  }
  return nodeTree.toArray(new Node[0]);
}
origin: gephi/graphstore

public void indexView(Graph graph) {
  TimeIndexImpl viewIndex = viewIndexes.get(graph.getView());
  if (viewIndex != null) {
    graph.readLock();
    try {
      Iterator<T> iterator = null;
      if (elementType.equals(Node.class)) {
        iterator = (Iterator<T>) graph.getNodes().iterator();
      } else if (elementType.equals(Edge.class)) {
        iterator = (Iterator<T>) graph.getEdges().iterator();
      }
      if (iterator != null) {
        while (iterator.hasNext()) {
          Element element = iterator.next();
          S set = getTimeSet(element);
          if (set != null) {
            K[] ts = set.toArray();
            int tsLength = ts.length;
            for (int i = 0; i < tsLength; i++) {
              int timestamp = timeSortedMap.get(ts[i]);
              viewIndex.add(timestamp, element);
            }
          }
        }
      }
    } finally {
      graph.readUnlock();
    }
  }
}
origin: org.gephi/datalab-api

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

  /**
   * See https://github.com/gephi/gephi/issues/603 Nodes position to NaN on applied layout
   *
   * @param graphModel
   */
  public static void ensureSafeLayoutNodePositions(GraphModel graphModel) {
    Graph graph = graphModel.getGraph();
    NodeIterable nodesIterable = graph.getNodes();
    for (Node node : nodesIterable) {
      if (node.x() != 0 || node.y() != 0) {
        nodesIterable.doBreak();
        return;
      }
    }

    //All at 0.0, init some random positions
    nodesIterable = graph.getNodes();
    for (Node node : nodesIterable) {
      node.setX((float) ((0.01 + Math.random()) * 1000) - 500);
      node.setY((float) ((0.01 + Math.random()) * 1000) - 500);
    }
  }
}
origin: org.gephi/tools-plugin

public static Node[] getNeighborsOfNeighbors(Graph graph, Node[] nodes) {
  Set<Node> nodeTree = new HashSet<>();
  graph.readLock();
  try {
    for (Node n : nodes) {
      nodeTree.addAll(graph.getNeighbors(n).toCollection());
    }
    //remove original nodes
    for (Node n : nodes) {
      nodeTree.remove(n);
    }
    for (Node n : nodeTree.toArray(new Node[0])) {
      nodeTree.addAll(graph.getNeighbors(n).toCollection());
    }
  } finally {
    graph.readUnlock();
  }
  //remove original nodes
  for (Node n : nodes) {
    nodeTree.remove(n);
  }
  return nodeTree.toArray(new Node[0]);
}
origin: org.gephi/graphstore

Iterator<T> iterator = null;
if (columnStore.elementType.equals(Node.class)) {
  iterator = (Iterator<T>) graph.getNodes().iterator();
} else if (columnStore.elementType.equals(Edge.class)) {
  iterator = (Iterator<T>) graph.getEdges().iterator();
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/statistics-plugin

private double calculateR(Graph graph, double[] pagerankValues, HashMap<Node, Integer> indicies, boolean directed, double prob) {
  int N = graph.getNodeCount();
  double r = (1.0 - prob) / N;//Initialize to damping factor
  //Calculate dangling nodes (nodes without out edges) contribution to all other nodes.
  //Necessary for all nodes page rank values sum to be 1
  NodeIterable nodesIterable = graph.getNodes();
  double danglingNodesRankContrib = 0;
  for (Node s : graph.getNodes()) {
    int s_index = indicies.get(s);
    int outDegree;
    if (directed) {
      outDegree = ((DirectedGraph) graph).getOutDegree(s);
    } else {
      outDegree = graph.getDegree(s);
    }
    if (outDegree == 0) {
      danglingNodesRankContrib += pagerankValues[s_index];
    }
    if (isCanceled) {
      nodesIterable.doBreak();
      break;
    }
  }
  danglingNodesRankContrib *= prob / N;
  r += danglingNodesRankContrib;
  return r;
}
origin: org.gephi/filters-plugin

Collection<Node> nodes = graph.getNodes().toCollection();
origin: gephi/graphstore

Iterator<T> iterator = null;
if (columnStore.elementType.equals(Node.class)) {
  iterator = (Iterator<T>) graph.getNodes().iterator();
} else if (columnStore.elementType.equals(Edge.class)) {
  iterator = (Iterator<T>) graph.getEdges().iterator();
origin: org.gephi/filters-plugin

for (Node node : graph.getNodes().toArray()) {
  if (!result.contains(node)) {
    graph.removeNode(node);
org.gephi.graph.apiNodeIterable

Javadoc

A node iterable.

Most used methods

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

Popular in Java

  • Making http requests using okhttp
  • addToBackStack (FragmentTransaction)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • findViewById (Activity)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now