本文整理了Java中org.jgrapht.Graph.getAllEdges()
方法的一些代码示例,展示了Graph.getAllEdges()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.getAllEdges()
方法的具体详情如下:
包路径:org.jgrapht.Graph
类名称:Graph
方法名:getAllEdges
[英]Returns a set of all edges connecting source vertex to target vertex if such vertices exist in this graph. If any of the vertices does not exist or is null
, returns null
. If both vertices exist but no edges found, returns an empty set.
In undirected graphs, some of the returned edges may have their source and target vertices in the opposite order. In simple graphs the returned set is either singleton set or empty set.
[中]如果此图中存在连接源顶点和目标顶点的所有边,则返回这些边的集合。如果任何顶点不存在或为null
,则返回null
。如果两个顶点都存在但未找到边,则返回空集。
在无向图中,一些返回边的源顶点和目标顶点的顺序可能相反。在简单图中,返回的集是单例集或空集。
代码示例来源:origin: org.jgrapht/jgrapht-core
/**
* {@inheritDoc}
*/
@Override
public Set<E> getAllEdges(V sourceVertex, V targetVertex)
{
return delegate.getAllEdges(sourceVertex, targetVertex);
}
代码示例来源:origin: cwensel/cascading
public Set<Scope> getAllEdges( FlowElement sourceVertex, FlowElement targetVertex )
{
return graph.getAllEdges( sourceVertex, targetVertex );
}
代码示例来源:origin: girtel/Net2Plan
/** Check whether the topology has the same number of links between each node pair in both directions (assuming multi-digraphs).
*
* @param graph The graph to analyze
* @return {@code true} if the graph is bidirectional, and false otherwise */
public static boolean isBidirectional(org.jgrapht.Graph graph)
{
Object[] vertices = graph.vertexSet().toArray();
for (int v1 = 0; v1 < vertices.length; v1++)
for (int v2 = v1 + 1; v2 < vertices.length; v2++)
if (graph.getAllEdges(vertices[v1], vertices[v2]).size() != graph.getAllEdges(vertices[v2], vertices[v1]).size()) return false;
return true;
}
代码示例来源:origin: girtel/Net2Plan
/** Check whether the graph is simple, that is, if it has at most one link between each node pair (one per direction under directed graphs, one under undirected graphs).
*
* @param graph The graph to analyze
* @return {@code true} if the graph is simple, and false otherwise */
public static boolean isSimple(org.jgrapht.Graph graph)
{
Object[] vertices = graph.vertexSet().toArray();
for (int v1 = 0; v1 < vertices.length; v1++)
{
for (int v2 = v1 + 1; v2 < vertices.length; v2++)
{
if (graph.getAllEdges(vertices[v1], vertices[v2]).size() > 1) return false;
if (graph.getAllEdges(vertices[v2], vertices[v1]).size() > 1) return false;
}
}
return true;
}
代码示例来源:origin: org.jgrapht/jgrapht-core
/**
* {@inheritDoc}
*/
@Override
public Set<E> getAllEdges(V sourceVertex, V targetVertex)
{
if (containsVertex(sourceVertex) && containsVertex(targetVertex)) {
return base
.getAllEdges(sourceVertex, targetVertex).stream().filter(edgeSet::contains)
.collect(Collectors.toCollection(LinkedHashSet::new));
} else {
return null;
}
}
代码示例来源:origin: org.jgrapht/jgrapht-core
/**
* {@inheritDoc}
*/
@Override
public Set<E> getAllEdges(V sourceVertex, V targetVertex)
{
boolean inG1 = g1.containsVertex(sourceVertex) && g1.containsVertex(targetVertex);
boolean inG2 = g2.containsVertex(sourceVertex) && g2.containsVertex(targetVertex);
if (inG1 && inG2) {
return new UnmodifiableUnionSet<>(
g1.getAllEdges(sourceVertex, targetVertex),
g2.getAllEdges(sourceVertex, targetVertex));
} else if (inG1) {
return Collections.unmodifiableSet(g1.getAllEdges(sourceVertex, targetVertex));
} else if (inG2) {
return Collections.unmodifiableSet(g2.getAllEdges(sourceVertex, targetVertex));
}
return Collections.emptySet();
}
代码示例来源:origin: girtel/Net2Plan
Set links_12 = graph.getAllEdges(vertices[vertexId_1], vertices[vertexId_2]);
Set links_21 = graph.getAllEdges(vertices[vertexId_2], vertices[vertexId_1]);
代码示例来源:origin: org.jgrapht/jgrapht-core
/**
* {@inheritDoc}
*/
@Override
public Set<E> getAllEdges(V sourceVertex, V targetVertex)
{
if (containsVertex(sourceVertex) && containsVertex(targetVertex)) {
return new MaskEdgeSet<>(
base, base.getAllEdges(sourceVertex, targetVertex), vertexMask, edgeMask);
} else
return null;
}
代码示例来源:origin: cwensel/cascading
@Override
public Set<Edge> getAllEdges( Object sourceVertex, Object targetVertex )
{
Node lhsNode = getVertex( (int) sourceVertex );
Node rhsNode = getVertex( ( (int) targetVertex ) );
return getDelegate().getAllEdges( lhsNode, rhsNode );
}
代码示例来源:origin: org.jgrapht/jgrapht-core
private void performLazyInspection()
{
if (blocks == null) {
init();
// Iterate over all connected components
for (V v : graph.vertexSet()) {
if (discTime.get(v) == -1) {
connectedSet = new HashSet<>();
dfs(v, null);
// Stack can be non-empty when dfs finishes, for instance if the graph has no
// cutpoints.
// Construct the final component from the remaining edges.
if (!stack.isEmpty())
buildBlock(0);
connectedSets.add(connectedSet);
}
}
if (this.graph.getType().isAllowingMultipleEdges()) {
// check parallel edges: an edge is not a bridge when there are multiple edges
// between the same pair of vertices
for (Iterator<E> it = bridges.iterator(); it.hasNext();) {
E edge = it.next();
int nrParallelEdges = graph
.getAllEdges(graph.getEdgeSource(edge), graph.getEdgeTarget(edge)).size();
if (nrParallelEdges > 1)
it.remove();
}
}
}
}
代码示例来源:origin: org.jgrapht/jgrapht-core
Set<E> edges = base.getAllEdges(sourceVertex, targetVertex);
代码示例来源:origin: org.jgrapht/jgrapht-io
for (int i = 0; i <= j; i++) {
if (g.containsEdge(vertices.get(i), vertices.get(j))) {
for (int p = 0; p < g.getAllEdges(vertices.get(i), vertices.get(j)).size();
p++)
代码示例来源:origin: org.jgrapht/jgrapht-core
if (!isAllowingMultipleEdges || graph.getAllEdges(u, v).size() == 1)
continue;
代码示例来源:origin: cwensel/cascading
continue;
if( contracted.getAllEdges( inner, outer ).isEmpty() )
excludeEdges.addAll( full.getAllEdges( inner, outer ) );
内容来源于网络,如有侵权,请联系作者删除!