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

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

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

Graph.containsEdge介绍

[英]Returns true if this graph contains the specified edge. More formally, returns true if and only if this graph contains an edge e2 such that e.equals(e2). If the specified edge is null returns false.
[中]如果此图形包含指定的边,则返回true。更正式地说,当且仅当此图包含一条边e2,即e.equals(e2)时,返回true。如果指定的边为null,则返回false

代码示例

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

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

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

/**
 * {@inheritDoc}
 */
@Override
public boolean containsEdge(E e)
{
  return g1.containsEdge(e) || g2.containsEdge(e);
}

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

public boolean containsEdge( FlowElement sourceVertex, FlowElement targetVertex )
 {
 return graph.containsEdge( sourceVertex, targetVertex );
 }

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

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

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

/**
 * Reports whether a vertex has at least one nonneighbour in X
 * 
 * @param g A Graph
 * @param v A Vertex
 * @param X A set of vertices
 * @return whether v has a nonneighbour in X
 */
private boolean hasANonneighbourInX(Graph<V, E> g, V v, Set<V> X)
{
  return X.stream().anyMatch(x -> !g.containsEdge(v, x));
}

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

/**
 * Reports whether v has at least one neighbour in set
 * 
 * @param g A Graph
 * @param set A set of vertices
 * @param v A vertex
 * @return whether v has at least one neighbour in set
 */
private boolean hasANeighbour(Graph<V, E> g, Set<V> set, V v)
{
  return set.stream().anyMatch(s -> g.containsEdge(s, v));
}

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

/**
 * A vertex y is X-complete if y contained in V(g)\X is adjacent to every vertex in X.
 * 
 * @param g A Graph
 * @param y Vertex whose X-completeness is to assess
 * @param X Set of vertices
 * @return whether y is X-complete
 */
boolean isYXComplete(Graph<V, E> g, V y, Set<V> X)
{
  return X.stream().allMatch(t -> g.containsEdge(t, y));
}

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

/**
 * N(a,b) is the set of all {a,b}-complete vertices
 * 
 * @param g A Graph
 * @param a A Vertex
 * @param b A Vertex
 * @return The set of all {a,b}-complete vertices
 */
private Set<V> N(Graph<V, E> g, V a, V b)
{
  return g
    .vertexSet().stream().filter(t -> g.containsEdge(t, a) && g.containsEdge(t, b))
    .collect(Collectors.toSet());
}

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

/**
 * A triple (a,b,c) of vertices is relevant if a,b are distinct and nonadjacent, and c is not
 * contained in N(a,b) (possibly c is contained in {a,b}).
 * 
 * @param g A graph
 * @param a A vertex
 * @param b A vertex
 * @param c A vertex
 * @return Assessement whether a,b,c is a relevant triple
 */
private boolean isTripleRelevant(Graph<V, E> g, V a, V b, V c)
{
  return a != b && !g.containsEdge(a, b) && !N(g, a, b).contains(c);
}

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

/**
 * {@inheritDoc}
 */
@Override
public V getEdgeTarget(E e)
{
  if (g1.containsEdge(e)) {
    return g1.getEdgeTarget(e);
  }
  if (g2.containsEdge(e)) {
    return g2.getEdgeTarget(e);
  }
  return null;
}

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

/**
 * {@inheritDoc}
 */
@Override
public V getEdgeSource(E e)
{
  if (g1.containsEdge(e)) {
    return g1.getEdgeSource(e);
  }
  if (g2.containsEdge(e)) {
    return g2.getEdgeSource(e);
  }
  return null;
}

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

/**
 * {@inheritDoc}
 */
@Override
public double getEdgeWeight(E e)
{
  if (g1.containsEdge(e) && g2.containsEdge(e)) {
    return operator.combine(g1.getEdgeWeight(e), g2.getEdgeWeight(e));
  }
  if (g1.containsEdge(e)) {
    return g1.getEdgeWeight(e);
  }
  if (g2.containsEdge(e)) {
    return g2.getEdgeWeight(e);
  }
  throw new IllegalArgumentException("no such edge in the union");
}

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

private void writeGraph6(Graph<V, E> g, List<V> vertices)
  throws IOException
{
  writeNumberOfVertices(vertices.size());
  // Write the lower triangle of the adjacency matrix of G as a bit vector x of length
  // n(n-1)/2,
  // using the ordering (0,1),(0,2),(1,2),(0,3),(1,3),(2,3),...,(n-1,n).
  for (int i = 0; i < vertices.size(); i++)
    for (int j = 0; j < i; j++)
      writeBit(g.containsEdge(vertices.get(i), vertices.get(j)));
  writeByte(); // Finish writing the last byte
}

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

private double computeLocalClusteringCoefficient(V v)
{
  if (scores.containsKey(v)) {
    return scores.get(v);
  }
  NeighborCache<V, E> neighborCache = new NeighborCache<>(graph);
  Set<V> neighbourhood = neighborCache.neighborsOf(v);
  final double k = neighbourhood.size();
  double numberTriplets = 0;
  for (V p : neighbourhood)
    for (V q : neighbourhood)
      if (graph.containsEdge(p, q))
        numberTriplets++;
  if (k <= 1)
    return 0.0;
  else
    return numberTriplets / (k * (k - 1));
}

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

public boolean addEdge( FlowElement sourceVertex, FlowElement targetVertex, Scope scope )
 {
 // prevent multiple edges from head or to tail
 if( !allowMultipleExtentEdges() && ( sourceVertex == Extent.head || targetVertex == Extent.tail ) && graph.containsEdge( sourceVertex, targetVertex ) )
  return true;
 return graph.addEdge( sourceVertex, targetVertex, scope );
 }

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

private V getEdgeSource(E e)
{
  return this.workingGraph.containsEdge(e) ? this.workingGraph.getEdgeSource(e)
    : this.originalGraph.getEdgeSource(e);
}

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

private V getEdgeTarget(E e)
{
  return this.workingGraph.containsEdge(e) ? this.workingGraph.getEdgeTarget(e)
    : this.originalGraph.getEdgeTarget(e);
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean addEdge(V sourceVertex, V targetVertex, E e)
{
  if (e == null) {
    throw new NullPointerException();
  }
  if (!base.containsEdge(e)) {
    throw new IllegalArgumentException(NO_SUCH_EDGE_IN_BASE);
  }
  assertVertexExist(sourceVertex);
  assertVertexExist(targetVertex);
  assert (base.getEdgeSource(e) == sourceVertex);
  assert (base.getEdgeTarget(e) == targetVertex);
  return edgeSet.add(e);
}

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

public Scope addEdge( FlowElement sourceVertex, FlowElement targetVertex )
  {
//     prevent multiple edges from head or to tail
  if( !allowMultipleExtentEdges() && ( sourceVertex == Extent.head || targetVertex == Extent.tail ) && graph.containsEdge( sourceVertex, targetVertex ) )
   return graph.getEdge( sourceVertex, targetVertex );

  return graph.addEdge( sourceVertex, targetVertex );
  }

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

public boolean containsEdge( int lhsVertex, int rhsVertex )
 {
 return getDelegate().containsEdge( getVertex( lhsVertex ), getVertex( rhsVertex ) );
 }

相关文章