本文整理了Java中org.jgrapht.Graph.removeVertex()
方法的一些代码示例,展示了Graph.removeVertex()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.removeVertex()
方法的具体详情如下:
包路径:org.jgrapht.Graph
类名称:Graph
方法名:removeVertex
[英]Removes the specified vertex from this graph including all its touching edges if present. More formally, if the graph contains a vertex u
such that u.equals(v)
, the call removes all edges that touch u
and then removes u
itself. If no such u
is found, the call leaves the graph unchanged. Returns true if the graph contained the specified vertex. (The graph will not contain the specified vertex once the call returns).
If the specified vertex is null
returns false
.
[中]从此图形中删除指定顶点,包括其所有接触边(如果存在)。更正式地说,如果图形包含一个顶点u
,这样u.equals(v)
,则调用将删除所有接触u
的边,然后删除u
本身。如果没有找到这样的u
,则调用将保持图形不变。如果图形包含指定的顶点,则返回true。(一旦调用返回,图形将不包含指定的顶点)。
如果指定的顶点为null
,则返回false
。
代码示例来源:origin: org.jgrapht/jgrapht-core
/**
* {@inheritDoc}
*/
@Override
public boolean removeVertex(V v)
{
return delegate.removeVertex(v);
}
代码示例来源:origin: cwensel/cascading
public boolean removeVertex( FlowElement flowElement )
{
return graph.removeVertex( flowElement );
}
代码示例来源:origin: Audiveris/audiveris
/**
* Remove a peak from the sequence of peaks.
*
* @param peak the peak to remove
*/
public void removePeak (StaffPeak peak)
{
if (peak.isVip()) {
logger.info("VIP {} removing {}", this, peak);
}
peaks.remove(peak);
peakGraph.removeVertex(peak);
}
代码示例来源:origin: org.jgrapht/jgrapht-core
/**
* Removes {@code vertex} from the graph being built, if such vertex exist in graph.
*
* @param vertex the vertex to remove
*
* @return this builder object
*
* @see Graph#removeVertex(Object)
*/
public B removeVertex(V vertex)
{
this.graph.removeVertex(vertex);
return this.self();
}
代码示例来源:origin: Galigator/openllet
@Override
protected List<ATermAppl> computeDefinitionOrder()
{
final List<ATermAppl> definitionOrder = CollectionUtils.makeList();
definitionOrder.add(TOP);
definitionOrder.addAll(getEquivalents(TOP));
_graph.removeVertex(TOP);
destructiveTopologocialSort(definitionOrder);
definitionOrder.add(BOTTOM);
return definitionOrder;
}
代码示例来源:origin: Galigator/openllet
@Override
protected List<ATermAppl> computeDefinitionOrder()
{
final List<ATermAppl> definitionOrder = CollectionUtils.makeList();
definitionOrder.add(TOP);
definitionOrder.addAll(getEquivalents(TOP));
_graph.removeVertex(TOP);
destructiveTopologocialSort(definitionOrder);
definitionOrder.add(BOTTOM);
return definitionOrder;
}
代码示例来源:origin: org.jgrapht/jgrapht-core
@Override
public VertexCover<V> getVertexCover()
{
Set<V> cover = new LinkedHashSet<>();
double weight = 0;
Graph<V, E> copy = new AsSubgraph<>(graph, null, null);
Map<V, Double> W = new HashMap<>();
for (V v : graph.vertexSet())
W.put(v, vertexWeightMap.get(v));
// Main loop
Set<E> edgeSet = copy.edgeSet();
while (!edgeSet.isEmpty()) {
// Pick arbitrary edge
E e = edgeSet.iterator().next();
V p = copy.getEdgeSource(e);
V q = copy.getEdgeTarget(e);
if (W.get(p) <= W.get(q)) {
W.put(q, W.get(q) - W.get(p));
cover.add(p);
weight += vertexWeightMap.get(p);
copy.removeVertex(p);
} else {
W.put(p, W.get(p) - W.get(q));
cover.add(q);
weight += vertexWeightMap.get(q);
copy.removeVertex(q);
}
}
return new VertexCoverAlgorithm.VertexCoverImpl<>(cover, weight);
}
代码示例来源:origin: org.jgrapht/jgrapht-core
sg.removeVertex(u);
sg.removeVertex(v);
代码示例来源:origin: Galigator/openllet
private void collapseCycle(final Set<ATermAppl> scc)
{
final Iterator<ATermAppl> i = scc.iterator();
final ATermAppl rep = i.next();
while (i.hasNext())
{
final ATermAppl node = i.next();
addEquivalent(rep, node);
for (final DefaultEdge edge : _graph.incomingEdgesOf(node))
{
final ATermAppl incoming = _graph.getEdgeSource(edge);
if (!incoming.equals(rep))
_graph.addEdge(incoming, rep);
}
for (final DefaultEdge edge : _graph.outgoingEdgesOf(node))
{
final ATermAppl outgoing = _graph.getEdgeTarget(edge);
if (!outgoing.equals(rep))
_graph.addEdge(rep, outgoing);
}
_graph.removeVertex(node);
}
}
代码示例来源:origin: Galigator/openllet
private void collapseCycle(final Set<ATermAppl> scc)
{
final Iterator<ATermAppl> i = scc.iterator();
final ATermAppl rep = i.next();
while (i.hasNext())
{
final ATermAppl node = i.next();
addEquivalent(rep, node);
for (final DefaultEdge edge : _graph.incomingEdgesOf(node))
{
final ATermAppl incoming = _graph.getEdgeSource(edge);
if (!incoming.equals(rep))
_graph.addEdge(incoming, rep);
}
for (final DefaultEdge edge : _graph.outgoingEdgesOf(node))
{
final ATermAppl outgoing = _graph.getEdgeTarget(edge);
if (!outgoing.equals(rep))
_graph.addEdge(rep, outgoing);
}
_graph.removeVertex(node);
}
}
代码示例来源:origin: org.jgrapht/jgrapht-core
hprime.removeVertex(v);
代码示例来源:origin: Galigator/openllet
public void destructiveTopologocialSort(final List<ATermAppl> nodesSorted)
{
final Queue<ATermAppl> nodesPending = createQueue();
for (final ATermAppl node : _graph.vertexSet())
if (_graph.outDegreeOf(node) == 0)
nodesPending.add(node);
while (!nodesPending.isEmpty())
{
final ATermAppl node = nodesPending.remove();
assert _graph.outDegreeOf(node) == 0;
nodesSorted.addAll(getAllEquivalents(node));
for (final DefaultEdge edge : _graph.incomingEdgesOf(node))
{
final ATermAppl source = _graph.getEdgeSource(edge);
if (_graph.outDegreeOf(source) == 1)
nodesPending.add(source);
}
_graph.removeVertex(node);
}
assert _graph.vertexSet().isEmpty() : "Failed to sort elements: " + _graph.vertexSet();
}
}
代码示例来源:origin: Galigator/openllet
public void destructiveTopologocialSort(final List<ATermAppl> nodesSorted)
{
final Queue<ATermAppl> nodesPending = createQueue();
for (final ATermAppl node : _graph.vertexSet())
if (_graph.outDegreeOf(node) == 0)
nodesPending.add(node);
while (!nodesPending.isEmpty())
{
final ATermAppl node = nodesPending.remove();
assert _graph.outDegreeOf(node) == 0;
nodesSorted.addAll(getAllEquivalents(node));
for (final DefaultEdge edge : _graph.incomingEdgesOf(node))
{
final ATermAppl source = _graph.getEdgeSource(edge);
if (_graph.outDegreeOf(source) == 1)
nodesPending.add(source);
}
_graph.removeVertex(node);
}
assert _graph.vertexSet().isEmpty() : "Failed to sort elements: " + _graph.vertexSet();
}
}
代码示例来源:origin: org.jgrapht/jgrapht-core
gprime.removeVertex(v);
vertexLabels.remove(v);
代码示例来源:origin: org.jgrapht/jgrapht-core
workingGraph.removeVertex(t);
workingGraph.removeVertex(s);
代码示例来源:origin: org.javabits.jgrapht/jgrapht-demo
public static boolean replaceVertex(Object oldVertex, Object newVertex)
{
if ((oldVertex == null) || (newVertex == null)) {
return false;
}
Set<DefaultEdge> relatedEdges = completeGraph.edgesOf(oldVertex);
completeGraph.addVertex(newVertex);
Object sourceVertex;
Object targetVertex;
for (DefaultEdge e : relatedEdges) {
sourceVertex = completeGraph.getEdgeSource(e);
targetVertex = completeGraph.getEdgeTarget(e);
if (sourceVertex.equals(oldVertex)
&& targetVertex.equals(oldVertex))
{
completeGraph.addEdge(newVertex, newVertex);
} else {
if (sourceVertex.equals(oldVertex)) {
completeGraph.addEdge(newVertex, targetVertex);
} else {
completeGraph.addEdge(sourceVertex, newVertex);
}
}
}
completeGraph.removeVertex(oldVertex);
return true;
}
}
代码示例来源:origin: SmartDataAnalytics/Sparqlify
selfJoinGraph.removeVertex(aliasB);
代码示例来源:origin: org.jgrapht/jgrapht-core
/**
* Removes the given vertex from the given graph. If the vertex to be removed has one or more
* predecessors, the predecessors will be connected directly to the successors of the vertex to
* be removed.
*
* @param graph graph to be mutated
* @param vertex vertex to be removed from this graph, if present
* @param <V> the graph vertex type
* @param <E> the graph edge type
*
* @return true if the graph contained the specified vertex; false otherwise.
*/
public static <V, E> boolean removeVertexAndPreserveConnectivity(Graph<V, E> graph, V vertex)
{
if (!graph.containsVertex(vertex)) {
return false;
}
if (vertexHasPredecessors(graph, vertex)) {
List<V> predecessors = Graphs.predecessorListOf(graph, vertex);
List<V> successors = Graphs.successorListOf(graph, vertex);
for (V predecessor : predecessors) {
addOutgoingEdges(graph, predecessor, successors);
}
}
graph.removeVertex(vertex);
return true;
}
内容来源于网络,如有侵权,请联系作者删除!