edu.uci.ics.jung.graph.Graph.removeEdge()方法的使用及代码示例

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

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

Graph.removeEdge介绍

暂无

代码示例

代码示例来源:origin: geogebra/geogebra

/**
 * @see edu.uci.ics.jung.graph.Hypergraph#removeEdge(java.lang.Object)
 */
@Override
public synchronized boolean removeEdge(E edge) {
  return delegate.removeEdge(edge);
}

代码示例来源:origin: geogebra/geogebra

/**
 * @see edu.uci.ics.jung.graph.Hypergraph#removeEdge(java.lang.Object)
 */
@Override
public boolean removeEdge(E edge) {
  return delegate.removeEdge(edge);
}

代码示例来源:origin: net.sf.jung/jung-api

/**
 * @see edu.uci.ics.jung.graph.Hypergraph#removeEdge(java.lang.Object)
 */
public boolean removeEdge(E edge) {
  return delegate.removeEdge(edge);
}

代码示例来源:origin: net.sf.jung/jung-api

/**
 * @see edu.uci.ics.jung.graph.Hypergraph#removeEdge(java.lang.Object)
 */
public synchronized boolean removeEdge(E edge) {
  return delegate.removeEdge(edge);
}

代码示例来源:origin: net.sf.jung/jung-visualization

public boolean removeEdge(E edge) {
  return graph.removeEdge(edge);
}
public boolean removeVertex(V vertex) {

代码示例来源:origin: net.sourceforge.jadex/jadex-tools-comanalyzer

/**
 * Removes an edge.
 * @param edge The edge to remove.
 * @return <code>true</code> if success.
 */
public boolean removeEdge(Object edge)
{
  internal_removeEdge(edge);
  return delegate.removeEdge(edge);
}

代码示例来源:origin: net.sf.jung/jung-visualization

public void actionPerformed(ActionEvent e) {
      pickedEdgeState.pick(edge, false);
      graph.removeEdge(edge);
      vv.repaint();
    }});
} else {

代码示例来源:origin: net.sf.jung/jung-api

/**
  * @see edu.uci.ics.jung.graph.Hypergraph#removeEdge(java.lang.Object)
  */
 @Override
public boolean removeEdge(E edge) {
   boolean state = delegate.removeEdge(edge);
   if(state) {
     GraphEvent<V,E> evt = new GraphEvent.Edge<V,E>(delegate, GraphEvent.Type.EDGE_REMOVED, edge);
     fireGraphEvent(evt);
   }
   return state;
 }

代码示例来源:origin: net.sf.jung/jung-algorithms

/**
 * Generates a graph whose degree distribution approximates a power-law.
 * @return the generated graph
 */
public Graph<V,E> get() {
  Graph<V,E> graph = initializeGraph();
  List<V> vertices = new ArrayList<V>(graph.getVertices());
  for (int rIdx = 0; rIdx < mNumIterations; rIdx++) {
    V v = null;
    int degree = 0;
    do {
      v = vertices.get((int) (mRandom.nextDouble() * mNumVertices));
      degree = graph.degree(v);
    } while (degree == 0);
    List<E> edges = new ArrayList<E>(graph.getIncidentEdges(v));
    E randomExistingEdge = edges.get((int) (mRandom.nextDouble()*degree));
    // FIXME: look at email thread on a more efficient RNG for arbitrary distributions
    
    V x = vertices.get((int) (mRandom.nextDouble() * mNumVertices));
    V y = null;
    do {
      y = vertices.get((int) (mRandom.nextDouble() * mNumVertices));
    } while (mRandom.nextDouble() > ((graph.degree(y)+1)/mMaxDegree));
    if (!graph.isSuccessor(y,x) && x != y) {
      graph.removeEdge(randomExistingEdge);
      graph.addEdge(edgeFactory.get(), x, y);
    }
  }
  return graph;
}

代码示例来源:origin: SINTEF-9012/cloudml

public ArrayList<Vertex> drawFromDeploymentModel() {
  Collection<Edge> c = new ArrayList<Edge>(graph.getEdges());
  for (Edge e : c) {
    graph.removeEdge(e);
  }
  Collection<Vertex> vs = new ArrayList<Vertex>(graph.getVertices());
  for (Vertex ve : vs) {
    graph.removeVertex(ve);
  }
  ArrayList<Vertex> v = drawVerticesFromDeploymentModel(dmodel);
  drawEdgesFromDeploymentModel(dmodel, v);
  System.out.println(vv);
  return v;
}

代码示例来源:origin: geogebra/geogebra

graph.removeEdge(randomExistingEdge);
graph.addEdge(edgeFactory.create(), x, y);

代码示例来源:origin: org.cloudml/ui.graph

public void drawFromDeploymentModel(){
  Collection<Edge> c = new ArrayList<Edge>(graph.getEdges());
  for(Edge e : c)
    graph.removeEdge(e);
  Collection<Vertex> vs =new ArrayList<Vertex>(graph.getVertices());
  for(Vertex ve : vs)
    graph.removeVertex(ve);
  
  ArrayList<Vertex> v = drawVerticesFromDeploymentModel(dmodel);
  drawEdgesFromDeploymentModel(dmodel, v);
  nodeTypes.removeAll();
  nodeTypes.setModel(fillList());
}

代码示例来源:origin: org.opendaylight.controller.thirdparty/net.sf.jung2

/**
 * Generates a graph whose degree distribution approximates a power-law.
 * @return the generated graph
 */
public Graph<V,E> create() {
  Graph<V,E> graph = initializeGraph();
  List<V> vertices = new ArrayList<V>(graph.getVertices());
  for (int rIdx = 0; rIdx < mNumIterations; rIdx++) {
    V v = null;
    int degree = 0;
    do {
      v = vertices.get((int) (mRandom.nextDouble() * mNumVertices));
      degree = graph.degree(v);
    } while (degree == 0);
    List<E> edges = new ArrayList<E>(graph.getIncidentEdges(v));
    E randomExistingEdge = edges.get((int) (mRandom.nextDouble()*degree));
    // FIXME: look at email thread on a more efficient RNG for arbitrary distributions
    
    V x = vertices.get((int) (mRandom.nextDouble() * mNumVertices));
    V y = null;
    do {
      y = vertices.get((int) (mRandom.nextDouble() * mNumVertices));
    } while (mRandom.nextDouble() > ((graph.degree(y)+1)/mMaxDegree));
    if (!graph.isSuccessor(y,x) && x != y) {
      graph.removeEdge(randomExistingEdge);
      graph.addEdge(edgeFactory.create(), x, y);
    }
  }
  return graph;
}

代码示例来源:origin: net.sf.jung/jung-graph-impl

/**
 * Removes <code>edge</code> from this tree.
 * If <code>remove_subtree</code> is <code>true</code>, removes
 * the subtree rooted at the child vertex incident to <code>edge</code>.
 * Otherwise, leaves the subtree intact as a new component tree of this
 * forest.
 * @param edge the edge to remove
 * @param remove_subtree if <code>true</code>, remove the subtree
 * @return <code>true</code> iff the tree was modified
 */
public boolean removeEdge(E edge, boolean remove_subtree)
{
  if (!delegate.containsEdge(edge))
    return false;
  V child = getDest(edge);
  if (remove_subtree)
    return removeVertex(child);
  else
  {
    delegate.removeEdge(edge);
    return false;
  }
}

代码示例来源:origin: geogebra/geogebra

/**
 * Removes <code>edge</code> from this tree. If <code>remove_subtree</code>
 * is <code>true</code>, removes the subtree rooted at the child vertex
 * incident to <code>edge</code>. Otherwise, leaves the subtree intact as a
 * new component tree of this forest.
 * 
 * @param edge
 *            the edge to remove
 * @param remove_subtree
 *            if <code>true</code>, remove the subtree
 * @return <code>true</code> iff the tree was modified
 */
public boolean removeEdge(E edge, boolean remove_subtree) {
  if (!delegate.containsEdge(edge)) {
    return false;
  }
  V child = getDest(edge);
  if (remove_subtree) {
    return removeVertex(child);
  }
  delegate.removeEdge(edge);
  return false;
}

代码示例来源:origin: org.opendaylight.nic/of-renderer

protected List<E> reverseUpdateEdgesWeight(final Graph<V, E> graph, final  Transformer<V, Number> transformer,
                      final List<E> shortestPath, final V initial, final V destination) {
  for(final E edge1 : shortestPath){
    V src = graph.getSource(edge1);
    V dst = graph.getDest(edge1);
    graph.removeEdge(edge1);
    graph.addEdge(edge1, dst, src, EdgeType.DIRECTED);
  }
  final List<E> edges = new ArrayList<>(graph.getEdges());
  final Map<E, Number> map = new LinkedHashMap<>();
  edges.forEach(edge -> {
    final V source = graph.getSource(edge);
    final V dest = graph.getDest(edge);
    Number cost = calculateCost(transformer, edge, source, dest);
    map.put(edge,cost);
  });
  final DijkstraShortestPath<V, E> reversedDijkstra =
      new DijkstraShortestPath<>(graph, MapTransformer.getInstance(map));
  DijkstraShortestPath<V, E> validatedShortestPath = checkPath(initial, destination, reversedDijkstra);
  return validatedShortestPath != null ? reversedDijkstra.getPath(initial, destination) : new ArrayList<>();
}

代码示例来源:origin: uk.gov.dstl.baleen/baleen-orderers

/** Find and remove simple loops (e.g. a -> b -> a) from a Jung graph */
public static <V, E> void removeLoops(Graph<V, E> graph) {
 for (V v : graph.getVertices()) {
  for (E e : graph.getOutEdges(v)) {
   V dest = graph.getDest(e);
   E returnEdge = graph.findEdge(dest, v);
   if (returnEdge != null) {
    LOGGER.warn(
      "Loop detected between {} and {}. Original order will be preserved.",
      getName(v),
      getName(dest));
    graph.removeEdge(returnEdge);
   }
  }
 }
}

代码示例来源:origin: dstl/baleen

/** Find and remove simple loops (e.g. a -> b -> a) from a Jung graph */
public static <V, E> void removeLoops(Graph<V, E> graph) {
 for (V v : graph.getVertices()) {
  for (E e : graph.getOutEdges(v)) {
   V dest = graph.getDest(e);
   E returnEdge = graph.findEdge(dest, v);
   if (returnEdge != null) {
    LOGGER.warn(
      "Loop detected between {} and {}. Original order will be preserved.",
      getName(v),
      getName(dest));
    graph.removeEdge(returnEdge);
   }
  }
 }
}

代码示例来源:origin: girtel/Net2Plan

@Override
public void rebuildGraph()
{
  for (GUILink gl : new ArrayList<>(g.getEdges()))
    g.removeEdge(gl);
  for (GUINode gn : new ArrayList<>(g.getVertices()))
    g.removeVertex(gn);
  for (GUINode gn : callback.getVisualizationState().getCanvasAllGUINodes()) g.addVertex(gn);
  for (GUILink gl : callback.getVisualizationState().getCanvasAllGUILinks(true, true))
    g.addEdge(gl, gl.getOriginNode(), gl.getDestinationNode());
  updateAllVerticesXYPosition();
  refresh();
}

代码示例来源:origin: girtel/Net2Plan

/** This method reverse the path "path" in the graph "graph" and returns it.
 * 
 * @param graph the input graph which will not be changed.
 * @param path the path to reverse
 * @return a new graph with the reversed path
 * @since 0.3.0 */
private static <V, E> Graph<V, E> reverseEdges(Graph<V, E> graph, List<E> path)
{
  if (graph == null || path == null) throw new IllegalArgumentException();
  Graph<V, E> clone = new DirectedOrderedSparseMultigraph<V, E>();
  for (V v : graph.getVertices())
    clone.addVertex(v);
  for (E e : graph.getEdges())
    clone.addEdge(e, graph.getEndpoints(e));
  for (E link : path)
  {
    V src = clone.getSource(link);
    V dst = clone.getDest(link);
    clone.removeEdge(link);
    clone.addEdge(link, dst, src, EdgeType.DIRECTED);
  }
  return clone;
}

相关文章