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

x33g5p2x  于2022-01-19 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(215)

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

Edge.isSelfLoop介绍

[英]Returns true if this edge is a self-loop.
[中]如果此边是自循环,则返回true。

代码示例

代码示例来源:origin: org.gephi/graphstore

@Override
public boolean isSelfLoop(Edge edge) {
  return edge.isSelfLoop();
}

代码示例来源:origin: gephi/graphstore

@Override
public boolean isSelfLoop(final Edge edge) {
  return edge.isSelfLoop();
}

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

@Override
public boolean evaluate(Graph graph, Edge edge) {
  return !edge.isSelfLoop();
}

代码示例来源:origin: gephi/graphstore

@Override
public boolean isSelfLoop(Edge edge) {
  return edge.isSelfLoop();
}

代码示例来源:origin: org.gephi/graphstore

@Override
public boolean isSelfLoop(final Edge edge) {
  return edge.isSelfLoop();
}

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

@Override
public boolean evaluate(Graph graph, Node node) {
  EdgeIterable edgeIterable = graph.getEdges(node);
  for (Edge e : edgeIterable) {
    if (e.isSelfLoop()) {
      edgeIterable.doBreak();
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.gephi/visualization

public EdgeModel initModel(Edge edge, NodeModel sourceModel, NodeModel targetModelImpl) {
  EdgeModel edgeModel;
  if (edge.isSelfLoop()) {
    edgeModel = new SelfLoopModel(edge, sourceModel);
  } else {
    edgeModel = new Edge2dModel(edge, sourceModel, targetModelImpl);
  }
  return edgeModel;
}

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

void updateAutorithy(Graph graph, double[] newValues, double[] hubValues, boolean isDirected, Map<Node, Integer> indices) {
  double norm = 0;
  for (Node q : indices.keySet()) {
    double auth = 0;
    EdgeIterable edge_iter;
    if (isDirected) {
      edge_iter = ((DirectedGraph) graph).getInEdges(q);
    } else {
      edge_iter = graph.getEdges(q);
    }
    for (Edge edge : edge_iter) {
      if (!edge.isSelfLoop()) {
        Node p = graph.getOpposite(q, edge);
        auth += hubValues[indices.get(p)];
      }
    }
    newValues[indices.get(q)] = auth;
    norm += auth * auth;
    if (isCanceled) {
      return;
    }
  }
  norm = Math.sqrt(norm);
  if (norm > 0) {
    for (int i = 0; i < newValues.length; i++) {
      newValues[i] = newValues[i] / norm;
    }
  }
}

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

void updateHub(Graph graph, double[] newValues, double[] authValues, boolean isDirected, Map<Node, Integer> indices) {
  double norm = 0;
  for (Node p : indices.keySet()) {
    double hub = 0;
    EdgeIterable edge_iter;
    if (isDirected) {
      edge_iter = ((DirectedGraph) graph).getOutEdges(p);
    } else {
      edge_iter = graph.getEdges(p);
    }
    for (Edge edge : edge_iter) {
      if (!edge.isSelfLoop()) {
        Node r = graph.getOpposite(p, edge);
        hub += authValues[indices.get(r)];
      }
    }
    newValues[indices.get(p)] = hub;
    norm += hub * hub;
    if (isCanceled) {
      return;
    }
  }
  norm = Math.sqrt(norm);
  if (norm > 0) {
    for (int i = 0; i < newValues.length; i++) {
      newValues[i] = newValues[i] / norm;
    }
  }
}

代码示例来源:origin: gephi/gephi-plugins-bootcamp

@Override
public void execute(GraphModel graphModel) {
  Graph graph = graphModel.getGraphVisible();
  selfLoopCount = 0;
  totalEdgeCount = graph.getEdgeCount();
  for (Edge e : graph.getEdges()) {
    if (e.isSelfLoop()) {
      selfLoopCount++;
    }
  }
}

代码示例来源:origin: gephi/gephi-plugins-bootcamp

@Override
public boolean evaluate(Graph graph, Edge edge) {
  DirectedGraph directedGraph = (DirectedGraph) graph;
  //Make sure the edge is not  self loop
  if (!edge.isSelfLoop()) {
    //Get the potential mutual edge
    Edge mutualEdge = directedGraph.getMutualEdge(edge);
    //Remove the mutual edge if exists
    //Make sure only one of the two mutual edges will be removed
    if (mutualEdge != null && mutualEdge.getStoreId() < edge.getStoreId()) {
      return false;
    }
  }
  return true;
}

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

private void setInitialValues(Graph graph, Map<Node, Integer> indicies, double[] pagerankValues, double[] weights, boolean directed, boolean useWeights) {
  final int N = graph.getNodeCount();
  for (Node s : graph.getNodes()) {
    final int index = indicies.get(s);
    pagerankValues[index] = 1.0 / N;
    if (useWeights) {
      double sum = 0;
      EdgeIterable eIter;
      if (directed) {
        eIter = ((DirectedGraph) graph).getOutEdges(s);
      } else {
        eIter = ((UndirectedGraph) graph).getEdges(s);
      }
      for (Edge edge : eIter) {
        if(!edge.isSelfLoop()){
          sum += edge.getWeight();
        }
      }
      weights[index] = sum;
    }
  }
}

代码示例来源:origin: gephi/gephi-plugins-bootcamp

@Override
  public void actionPerformed(ActionEvent e) {
    //Get the current graph model
    GraphController gc = Lookup.getDefault().lookup(GraphController.class);
    GraphModel graphModel = gc.getGraphModel();

    if (graphModel != null) {
      //Remove self loops
      int removed = 0;
      Graph graph = graphModel.getGraph();
      graph.writeLock();
      for (Edge edge : graph.getEdges().toArray()) {
        if (edge.isSelfLoop()) {
          graph.removeEdge(edge);
          removed++;
        }
      }
      graph.writeUnlock();

      //Notification message
      NotifyDescriptor d = new NotifyDescriptor.Message(removed + " self-loop have been removed", NotifyDescriptor.INFORMATION_MESSAGE);
      DialogDisplayer.getDefault().notify(d);
    } else {
      //Error message
      NotifyDescriptor d = new NotifyDescriptor.Message("No active workspace", NotifyDescriptor.ERROR_MESSAGE);
      DialogDisplayer.getDefault().notify(d);
    }

  }
}

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

private Map<Node, Set<Node>> calculateInNeighborsPerNode(Graph graph, boolean directed) {
  Map<Node, Set<Node>> inNeighborsPerNode = new Object2ObjectOpenHashMap<>();
  NodeIterable nodesIterable = graph.getNodes();
  for (Node node : nodesIterable) {
    Set<Node> nodeInNeighbors = new ObjectOpenHashSet<>();
    EdgeIterable edgesIterable;
    if (directed) {
      edgesIterable = ((DirectedGraph) graph).getInEdges(node);
    } else {
      edgesIterable = graph.getEdges(node);
    }
    for (Edge edge : edgesIterable) {
      if (!edge.isSelfLoop()) {
        Node neighbor = graph.getOpposite(node, edge);
        nodeInNeighbors.add(neighbor);
      }
      if (isCanceled) {
        edgesIterable.doBreak();
        break;
      }
    }
    inNeighborsPerNode.put(node, nodeInNeighbors);
    if (isCanceled) {
      nodesIterable.doBreak();
      break;
    }
  }
  return inNeighborsPerNode;
}

代码示例来源:origin: gephi/gephi-plugins-bootcamp

for (Edge e : edges) {
  for (Edge f : edges) {
    if (e != f && graph.contains(e) && graph.contains(f) && !e.isSelfLoop() && !f.isSelfLoop()) {
      Node s1 = e.getSource();
      Node t1 = e.getTarget();

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

} else {
  for (Edge e : graph.getEdges(n)) {
    totalWeight += (e.isSelfLoop() ? 2 : 1) * e.getWeight();

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

if (!edge.isSelfLoop()) {
  Node neighbor = graph.getOpposite(node, edge);
  inWeightPerNeighbor.addTo(neighbor, edge.getWeight());

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

@Override
public Item[] getItems(Graph graph) {
  EdgeItem[] items = new EdgeItem[graph.getEdgeCount()];
  int i = 0;
  for (Edge e : graph.getEdges()) {
    EdgeItem item = new EdgeItem(e);
    item.setData(EdgeItem.WEIGHT, e.getWeight(graph.getView()));
    item.setData(EdgeItem.DIRECTED, e.isDirected());
    if (graph.isDirected(e)) {
      item.setData(EdgeItem.MUTUAL, ((DirectedGraph) graph).getMutualEdge(e) != null);
    }
    item.setData(EdgeItem.SELF_LOOP, e.isSelfLoop());
    item.setData(EdgeItem.COLOR, e.alpha() == 0 ? null : e.getColor());
    items[i++] = item;
  }
  return items;
}

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

(Color) targetItem.getData(NodeItem.COLOR));
item.setData(EDGE_COLOR, color);
if (edge.isSelfLoop()) {

相关文章