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

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

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

Graph.addEdge介绍

[英]Adds an edge to this graph.
[中]将边添加到此图形。

代码示例

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

@Override
public Edge createEdge(String id, Node source, Node target, boolean directed, Object typeLabel, Graph graph) {
  Edge newEdge = buildEdge(graph, id, source, target, directed, typeLabel);
  try {
    if (graph.addEdge(newEdge)) {//The edge will be created if it does not already exist.
      return newEdge;
    }
  } catch (Exception e) {
    Logger.getLogger("").log(
        Level.SEVERE, 
        "Error when adding edge [id = {0}, source = {1}, target = {2}, directed = {3}, typeLabel = {4}] to the graph. Exception message: {5}",
        new Object[]{id, source.getId(), target.getId(), directed, typeLabel, e.getMessage()}
    );
  }
  return null;
}

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

graph.addEdge(edge);

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

if (n != m && graph.getEdge(n, m) == null) {
  Edge e = graphModel.factory().newEdge(n, m);
  graph.addEdge(e);

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

graph.addEdge(edge);

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

graph.addEdge(e);

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

@Override
  public void clickNodes(Node[] nodes) {
    //Get mouse position
    float[] position3d = VizController.getInstance().getGraphIO().getMousePosition3d();
    //Get current graph
    GraphController gc = Lookup.getDefault().lookup(GraphController.class);
    Graph graph = gc.getGraphModel().getGraph();
    GraphFactory factory = gc.getGraphModel().factory();
    //Add node
    Node node = factory.newNode();
    node.setX(position3d[0]);
    node.setY(position3d[1]);
    node.setSize(10f);
    graph.addNode(node);
    //Add edges with the clicked nodes
    for (Node n : nodes) {
      Edge edge = factory.newEdge(node, n);
      graph.addEdge(edge);
    }
  }
}};

代码示例来源: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 (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) {
        //The edge is not in graph
        graph.addEdge(e);
      } else {
        //The edge is in the graph
        graph.removeEdge(edgeInGraph);
      }
    }
  }
  return graph;
}

代码示例来源: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;
}

相关文章