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

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

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

Graph.getEdgeSource介绍

[英]Returns the source vertex of an edge. For an undirected graph, source and target are distinguishable designations (but without any mathematical meaning).
[中]返回边的源顶点。对于无向图,源和目标是可区分的名称(但没有任何数学意义)。

代码示例

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

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

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

/**
 * {@inheritDoc}
 */
@Override
public V getEdgeSource(E e)
{
  return base.getEdgeSource(e);
}

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

public FlowElement getEdgeSource( Scope scope )
 {
 return graph.getEdgeSource( 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: SmartDataAnalytics/jena-sparql-api

public static <V, E> Set<V> sources(Graph<V, E> graph, Collection<E> edges) {
  Set<V> result = edges.stream()
      .map(e -> graph.getEdgeSource(e))
      .collect(Collectors.toSet());
  return result;
}

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

public int[] getEdgeNumbers(E e)
{
  V v1 = graph.getEdgeSource(e), v2 = graph.getEdgeTarget(e);
  int[] edge = new int[2];
  edge[0] = mapVertexToOrder.get(v1);
  edge[1] = mapVertexToOrder.get(v2);
  return edge;
}

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

private boolean isEqualsStraightOrInverted(Object sourceVertex, Object targetVertex, E e)
{
  boolean equalStraight = sourceVertex.equals(graph.getEdgeSource(e))
    && targetVertex.equals(graph.getEdgeTarget(e));
  boolean equalInverted = sourceVertex.equals(graph.getEdgeTarget(e))
    && targetVertex.equals(graph.getEdgeSource(e));
  return equalStraight || equalInverted;
}

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

/**
 * {@inheritDoc}
 */
@Override
public V getEdgeSource(E edge)
{
  assert (edgeSet().contains(edge));
  return base.getEdgeSource(edge);
}

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

/**
 * {@inheritDoc}
 */
@Override
public Iterator<E> iterator()
{
  return edgeSet
    .stream()
    .filter(
      e -> !edgeMask.test(e) && !vertexMask.test(graph.getEdgeSource(e))
        && !vertexMask.test(graph.getEdgeTarget(e)))
    .iterator();
}

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

/**
 * {@inheritDoc}
 */
@Override
public int size()
{
  return (int) edgeSet
    .stream()
    .filter(
      e -> !edgeMask.test(e) && !vertexMask.test(graph.getEdgeSource(e))
        && !vertexMask.test(graph.getEdgeTarget(e)))
    .count();
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean contains(Object o)
{
  if (!edgeSet.contains(o)) {
    return false;
  }
  E e = TypeUtil.uncheckedCast(o);
  return !edgeMask.test(e) && !vertexMask.test(graph.getEdgeSource(e))
    && !vertexMask.test(graph.getEdgeTarget(e));
}

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

@Override
  public Set<E> getCutEdges()
  {
    Set<E> cutEdges = new LinkedHashSet<>();
    Set<V> sourcePartion = this.getSourcePartition();
    for (E e : network.edgeSet()) {
      V source = network.getEdgeSource(e);
      V sink = network.getEdgeTarget(e);
      if (sourcePartion.contains(source) ^ sourcePartion.contains(sink))
        cutEdges.add(e);
    }
    return cutEdges;
  }
}

代码示例来源:origin: SmartDataAnalytics/jena-sparql-api

public static <V, E> Triplet<V, E> toTriplet(Graph<V, E> graph, E edge) {
  V s = graph.getEdgeSource(edge);
  V t = graph.getEdgeTarget(edge);
  Triplet<V, E> result = new TripletImpl<>(s, edge, t);
  return result;
}

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

private void debugCompatibleEdges( Collection<Scope> results, int v1, int v2, List<ScopeExpression> matchers )
 {
 for( Scope result : results )
  {
  FlowElement lhs = elementGraph.getDelegate().getEdgeSource( result );
  int lhsIndex = elementGraph.getIndex( lhs );
  FlowElement rhs = elementGraph.getDelegate().getEdgeTarget( result );
  int rhsIndex = elementGraph.getIndex( rhs );
  LOG.debug( "compatible edge: {}:{} -> {}:{}, having: {}", lhsIndex, lhs, rhsIndex, rhs, result.printSimple() );
  }
 for( ScopeExpression matcher : matchers )
  LOG.debug( " - {} -> {} matcher: {}", v1, v2, matcher );
 }

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

static public <V, E> void copyTo(Graph<V, E> source, Graph<V, E> target) {
  for (V vertex : source.vertexSet()) {
    target.addVertex(vertex);
  }
  for (E edge : source.edgeSet()) {
    final boolean added = target.addEdge(source.getEdgeSource(edge), source.getEdgeTarget(edge), edge);
    if (!added) {
      throw new IllegalArgumentException("Target graph does not support addition of (some) source edges.");
    }
  }
}

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

/**
 * {@inheritDoc}
 */
@Override
public void addEdgeToTouchingVertices(E e)
{
  V source = graph.getEdgeSource(e);
  V target = graph.getEdgeTarget(e);
  getEdgeContainer(source).addEdge(e);
  if (!source.equals(target)) {
    getEdgeContainer(target).addEdge(e);
  }
}

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

/**
 * {@inheritDoc}
 */
@Override
public void removeEdgeFromTouchingVertices(E e)
{
  V source = graph.getEdgeSource(e);
  V target = graph.getEdgeTarget(e);
  getEdgeContainer(source).removeEdge(e);
  if (!source.equals(target)) {
    getEdgeContainer(target).removeEdge(e);
  }
}

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

/**
 * {@inheritDoc}
 */
@Override
public void addEdgeToTouchingVertices(E e)
{
  V source = graph.getEdgeSource(e);
  V target = graph.getEdgeTarget(e);
  getEdgeContainer(source).addOutgoingEdge(e);
  getEdgeContainer(target).addIncomingEdge(e);
}

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

/**
 * {@inheritDoc}
 */
@Override
public void removeEdgeFromTouchingVertices(E e)
{
  V source = graph.getEdgeSource(e);
  V target = graph.getEdgeTarget(e);
  getEdgeContainer(source).removeOutgoingEdge(e);
  getEdgeContainer(target).removeIncomingEdge(e);
}

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

public DirectedMultiGraph( Graph<FlowElement, Scope> parent )
 {
 this();
 // safe to assume there are no unconnected vertices
 for( Scope edge : parent.edgeSet() )
  {
  FlowElement s = parent.getEdgeSource( edge );
  FlowElement t = parent.getEdgeTarget( edge );
  addVertex( s );
  addVertex( t );
  addEdge( s, t, edge );
  }
 }

相关文章