org.jgrapht.Graph.removeEdge()方法的使用及代码示例

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

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

Graph.removeEdge介绍

[英]Removes the specified edge from the graph. Removes the specified edge from this graph if it is present. More formally, removes an edge e2 such that e2.equals(e), if the graph contains such edge. Returns true if the graph contained the specified edge. (The graph will not contain the specified edge once the call returns).

If the specified edge is null returns false.
[中]从图形中删除指定的边。从该图形中删除指定的边(如果存在)。更正式地说,删除边e2,这样e2.equals(e),如果图形包含这样的边。如果图形包含指定的边,则返回true。(一旦调用返回,图形将不包含指定的边)。
如果指定的边为null,则返回false

代码示例

代码示例来源:origin: org.jgrapht/jgrapht-core

/**
 * {@inheritDoc}
 */
@Override
public boolean removeEdge(E e)
{
  return delegate.removeEdge(e);
}

代码示例来源:origin: org.jgrapht/jgrapht-core

/**
 * {@inheritDoc}
 */
@Override
public E removeEdge(V sourceVertex, V targetVertex)
{
  return delegate.removeEdge(sourceVertex, targetVertex);
}

代码示例来源:origin: cwensel/cascading

public Scope removeEdge( FlowElement sourceVertex, FlowElement targetVertex )
 {
 return graph.removeEdge( sourceVertex, targetVertex );
 }

代码示例来源:origin: cwensel/cascading

public boolean removeEdge( Scope scope )
 {
 return graph.removeEdge( scope );
 }

代码示例来源:origin: io.github.oliviercailloux.jmcda/utils

static public <V, E> void removeLoops(Graph<V, E> g) {
  for (V v : g.vertexSet()) {
    g.removeEdge(v, v);
  }
}

代码示例来源:origin: org.jgrapht/jgrapht-core

/**
 * Removes the specified edge from the graph. Removes the specified edge from this graph if it
 * is present.
 *
 * @param edge edge to be removed from this graph, if present.
 * @return this builder object
 *
 * @see Graph#removeEdge(Object)
 */
public B removeEdge(E edge)
{
  this.graph.removeEdge(edge);
  return this.self();
}

代码示例来源:origin: org.jgrapht/jgrapht-core

/**
 * Removes an edge going from source vertex to target vertex from the graph being built, if such
 * vertices and such edge exist in the graph.
 *
 * @param source source vertex of the edge.
 * @param target target vertex of the edge.
 *
 * @return this builder object
 *
 * @see Graph#removeVertex(Object)
 */
public B removeEdge(V source, V target)
{
  this.graph.removeEdge(source, target);
  return this.self();
}

代码示例来源:origin: org.danilopianini/jirf

private <S, D> void addEdge(
    final Class<S> source,
    final Class<D> target,
    final Function<? super S, ? extends D> implicit) {
  edgeFactory.addImplicitConversion(source, target, implicit);
  implicits.removeEdge(source, target);
  Objects.requireNonNull(implicits.addEdge(source, target));
}

代码示例来源:origin: org.jgrapht/jgrapht-core

if (!other.equals(v) && !target.containsEdge(v, other)) {
  if (!addInsteadOfRewire) {
    target.removeEdge(e);

代码示例来源:origin: org.jgrapht/jgrapht-core

if (!transitivelyReducedMatrix[i].get(j)) {
  directedGraph
    .removeEdge(directedGraph.getEdge(vertices.get(i), vertices.get(j)));

代码示例来源:origin: org.jgrapht/jgrapht-core

@Override
protected void transformGraph(List<E> previousPath)
{
  V source, target;
  E reversedEdge;
  // replace previous path edges with reversed edges with negative weight
  for (E originalEdge : previousPath) {
    source = workingGraph.getEdgeSource(originalEdge);
    target = workingGraph.getEdgeTarget(originalEdge);
    double originalEdgeWeight = workingGraph.getEdgeWeight(originalEdge);
    workingGraph.removeEdge(originalEdge);
    workingGraph.addEdge(target, source);
    reversedEdge = workingGraph.getEdge(target, source);
    workingGraph.setEdgeWeight(reversedEdge, -originalEdgeWeight);
  }
}

代码示例来源:origin: org.jgrapht/jgrapht-core

@Override
protected void transformGraph(List<E> previousPath)
{
  for (E edge : this.workingGraph.edgeSet()) {
    V source = workingGraph.getEdgeSource(edge);
    V target = workingGraph.getEdgeTarget(edge);
    double modifiedWeight = this.workingGraph.getEdgeWeight(edge)
      - singleSourcePaths.getWeight(target) + singleSourcePaths.getWeight(source);
    this.workingGraph.setEdgeWeight(edge, modifiedWeight);
  }
  E reversedEdge;
  for (E originalEdge : previousPath) {
    double zeroWeight = workingGraph.getEdgeWeight(originalEdge);
    if (zeroWeight != 0) {
      throw new IllegalStateException("Expected zero weight edge along the path");
    }
    V source = workingGraph.getEdgeSource(originalEdge);
    V target = workingGraph.getEdgeTarget(originalEdge);
    workingGraph.removeEdge(originalEdge);
    workingGraph.addEdge(target, source);
    reversedEdge = workingGraph.getEdge(target, source);
    workingGraph.setEdgeWeight(reversedEdge, zeroWeight);
  }
}

相关文章