本文整理汇总了Java中org.jgrapht.DirectedGraph.outgoingEdgesOf方法的典型用法代码示例。如果您正苦于以下问题:Java DirectedGraph.outgoingEdgesOf方法的具体用法?Java DirectedGraph.outgoingEdgesOf怎么用?Java DirectedGraph.outgoingEdgesOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jgrapht.DirectedGraph
的用法示例。
在下文中一共展示了DirectedGraph.outgoingEdgesOf方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConnectedTo
import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
@Override
public Object[] getConnectedTo(Object entity) {
if (entity instanceof PgStatement){
DirectedGraph<PgStatement, DefaultEdge> currentGraph = depRes.getOldGraph();
if (currentGraph != null){
List<PgStatement> connected = new ArrayList<>();
for (DefaultEdge e : currentGraph.outgoingEdgesOf((PgStatement)entity)){
PgStatement connectedVertex = currentGraph.getEdgeTarget(e);
if (!(connectedVertex instanceof PgColumn)) {
connected.add(connectedVertex);
}
}
return connected.toArray();
}
}
return null;
}
示例2: replaceVertex
import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
private static void replaceVertex(DirectedGraph<IAtomicDerivedStateProcessor<? extends EObject>, DefaultEdge> graph,
IAtomicDerivedStateProcessor<? extends EObject> original,
IAtomicDerivedStateProcessor<? extends EObject> replacement) {
Collection<DefaultEdge> edgeDump = new ArrayList<>();
for (DefaultEdge incomingEdge : graph.incomingEdgesOf(original)) {
IAtomicDerivedStateProcessor<? extends EObject> edgeSource = graph.getEdgeSource(incomingEdge);
edgeDump.add(incomingEdge);
graph.addEdge(edgeSource, replacement);
}
for (DefaultEdge outgoingEdge : graph.outgoingEdgesOf(original)) {
// we do not insert the dependencies of the removed vertex because the new vertex has its own dependencies
edgeDump.add(outgoingEdge);
}
edgeDump.forEach(graph::removeEdge);
graph.removeVertex(original);
}
示例3: getOutNeighbors
import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
public static Set<Node> getOutNeighbors(DirectedGraph<Node, DefaultLink> g, Node n) {
Set<Node> neighbors = new HashSet<Node>();
if (g == null || n == null || !g.vertexSet().contains(n))
return neighbors;
Set<DefaultLink> outgoingLinks = g.outgoingEdgesOf(n);
if (outgoingLinks != null) {
for (DefaultLink l : outgoingLinks) {
neighbors.add(l.getTarget());
}
}
return neighbors;
}
示例4: collapseGraph
import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
public DirectedGraph<FunctionVertex, CallEdge> collapseGraph() {
DirectedGraph<FunctionVertex, CallEdge> g = cloneGraph(graph);
List<FunctionVertex> vToRemove = new ArrayList<>();
for (int i = 0; i < 10; i++) {
vToRemove.clear();
/* remove all vertrtices with zero stack and no childs */
for (FunctionVertex fn : g.vertexSet()) {
Set<CallEdge> oe = g.outgoingEdgesOf(fn);
if (oe.isEmpty() && fn.stack == 0) {
vToRemove.add(fn);
}
}
g.removeAllVertices(vToRemove);
}
for (int i = 0; i < 1000; i++) {
traverseMaxStack(g);
}
return g;
}
示例5: write
import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
public static <V, E> void write(DirectedGraph<V, E> g, String fileName) throws FileNotFoundException {
try (PrintWriter out = new PrintWriter(fileName)) {
out.print("digraph \"DirectedGraph\" { \n graph [label=\"");
out.print(g.toString());
out.print("\", labelloc=t, concentrate=true]; ");
out.print("center=true;fontsize=12;node [fontsize=12];edge [fontsize=12]; \n");
for (V node : g.vertexSet()) {
out.print(" \"");
out.print(getId(node));
out.print("\" ");
out.print("[label=\"");
out.print(node.toString());
out.print("\" shape=\"box\" color=\"blue\" ] \n");
}
for (V src : g.vertexSet()) {
for (E e : g.outgoingEdgesOf(src)) {
V tgt = g.getEdgeTarget(e);
out.print(" \"");
out.print(getId(src));
out.print("\" -> \"");
out.print(getId(tgt));
out.print("\" ");
out.print("[label=\"");
out.print(e.toString());
out.print("\"]\n");
}
}
out.print("\n}");
out.flush();
}
}
示例6: getChildren
import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
public static <T> List<T> getChildren(DirectedGraph g, T n) {
List<IndexedEdge> outgoing = new ArrayList(g.outgoingEdgesOf(n));
List<T> ret = new ArrayList();
for(IndexedEdge e: outgoing) {
ret.add((T)e.target);
}
return ret;
}
示例7: neighbours
import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
@Override @NonNull public Set<String> neighbours() {
if (!hasTopology()) {
throw new IllegalStateException("Topology not ready.");
}
final DirectedGraph<String, DefaultEdge> graph = getCurrentTopologyGraph();
final Set<DefaultEdge> outEdges = graph.outgoingEdgesOf(identityService.nodeId());
return outEdges.stream().map(graph::getEdgeTarget).collect(Collectors.toSet());
}
示例8: testThreeNodes
import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
@Test public void testThreeNodes() {
final Map<String, NodeDescriptor> map = toMap(ImmutableSet.of("1", "2", "3"),
input -> new NodeDescriptor(input, NodeType.UNKNOWN,
Collections.emptySet()));
final Set<NodeDescriptor> identities = ImmutableSet.copyOf(map.values());
final DirectedGraph<String, DefaultEdge> graph = processor.createGraphFrom(identities);
map.keySet().forEach(nodeId -> {
assertThat(graph.containsVertex(nodeId)).isTrue();
assertThat(graph.inDegreeOf(nodeId)).isEqualTo(1);
assertThat(graph.outDegreeOf(nodeId)).isEqualTo(1);
assertThat(graph.getEdge(nodeId, nodeId)).isNull();
});
final String start = map.keySet().stream().findAny().get();
String current = start;
int counter = 0;
do {
final Set<DefaultEdge> outEdges = graph.outgoingEdgesOf(current);
assertThat(outEdges).hasSize(1);
current = graph.getEdgeTarget(getOnlyElement(outEdges));
counter++;
} while (!Objects.equals(current, start));
assertThat(counter).isEqualTo(3);
}
示例9: addSatisfiedStratum
import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
public void addSatisfiedStratum(TGDStratum tgdStratum) {
this.unsatisfiedStrataLock.lock();
try {
if (logger.isDebugEnabled()) logger.debug("** Stratum satisfied: " + tgdStratum);
this.unsatisfiedStrata.remove(tgdStratum);
this.unsatisfiedStrataCondition.signalAll();
DirectedGraph<TGDStratum, DefaultEdge> strataGraph = scenario.getStratification().getTgdStrataGraph();
for (DefaultEdge outEdge : strataGraph.outgoingEdgesOf(tgdStratum)) {
TGDStratum nextStratum = strataGraph.getEdgeTarget(outEdge);
this.startThreadForTGDStratum(nextStratum);
}
} finally {
this.unsatisfiedStrataLock.unlock();
}
}
示例10: addSatisfiedStratum
import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
public void addSatisfiedStratum(EGDStratum egdStratum) {
this.unsatisfiedStrataLock.lock();
try {
if (logger.isDebugEnabled()) logger.debug("** Stratum satisfied: " + egdStratum);
this.unsatisfiedStrata.remove(egdStratum);
this.unsatisfiedStrataCondition.signalAll();
DirectedGraph<EGDStratum, DefaultEdge> strataGraph = scenario.getStratification().getEgdStrataGraph();
for (DefaultEdge outEdge : strataGraph.outgoingEdgesOf(egdStratum)) {
EGDStratum nextStratum = strataGraph.getEdgeTarget(outEdge);
this.startThreadForEGDStratum(nextStratum);
}
} finally {
this.unsatisfiedStrataLock.unlock();
}
}
示例11: traverseMaxStack
import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
private void traverseMaxStack(DirectedGraph<FunctionVertex, CallEdge> g) {
int maxStack, fnStack;
for (FunctionVertex fn : g.vertexSet()) {
Set<CallEdge> ces = g.outgoingEdgesOf(fn);
if (ces.isEmpty()) {
if (fn.stack >= 0) {
fn.maxStack = fn.stack;
} else {
fn.maxStack = 0;
}
continue;
}
maxStack = -1;
for (CallEdge ce : ces) {
fnStack = g.getEdgeTarget(ce).maxStack;
if (fnStack >= 0) {
maxStack = Math.max(maxStack, fnStack);
} else {
maxStack = -1;
break;
}
}
if (maxStack >= 0) {
if (isRecursive(fn)) {
} else {
fn.maxStack = maxStack + fn.stack;
}
} else if (isRecursive(fn)) {
fn.maxStack = fn.stack;
}
}
}
示例12: getDirectDependencies
import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
public Collection<MappingDependency<T, C>> getDirectDependencies() {
final Map<MPackageInfo, MappingDependency<T, C>> dependencies = new HashMap<MPackageInfo, MappingDependency<T, C>>();
final DirectedGraph<InfoVertex<T, C>, DependencyEdge> graph = analyzer
.getGraph();
final Collection<InfoVertex<T, C>> vertices = new HashSet<InfoVertex<T, C>>(
getInfoVertices());
for (InfoVertex<T, C> sourceVertex : vertices) {
final Set<DependencyEdge> edges = graph
.outgoingEdgesOf(sourceVertex);
for (DependencyEdge edge : edges) {
if (edge.getType() == DependencyType.HARD) {
final InfoVertex<T, C> targetVertex = graph
.getEdgeTarget(edge);
final MPackageInfo packageInfo = targetVertex
.getPackageInfo();
// If this another package (not this package and not the
// built-in package)
if (packageInfo != null
&& !this.packageInfo.equals(packageInfo)) {
MappingDependency<T, C> dependency = dependencies
.get(packageInfo);
if (dependency == null) {
dependency = new MappingDependency<T, C>(
packageInfo);
dependencies.put(packageInfo, dependency);
}
dependency.addInfoVertex(targetVertex);
}
}
}
}
return dependencies.values();
}
示例13: includeInfoVertex
import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
private void includeInfoVertex(final InfoVertex<T, C> initialVertex) {
logger.trace(MessageFormat.format("Including the vertex [{0}].",
initialVertex));
final DirectedGraph<InfoVertex<T, C>, DependencyEdge> graph = analyzer
.getGraph();
final SortedMap<ContainmentType, Deque<InfoVertex<T, C>>> deques = new TreeMap<ContainmentType, Deque<InfoVertex<T, C>>>();
deques.put(ContainmentType.INCLUDED_EXPLICITLY,
new LinkedList<InfoVertex<T, C>>());
deques.put(ContainmentType.INCLUDED_AS_HARD_DEPENDENCY,
new LinkedList<InfoVertex<T, C>>());
deques.put(ContainmentType.INCLUDED_AS_SOFT_DEPENDENCY,
new LinkedList<InfoVertex<T, C>>());
deques.get(ContainmentType.INCLUDED_EXPLICITLY).add(initialVertex);
for (Map.Entry<ContainmentType, Deque<InfoVertex<T, C>>> dequeEntry : deques
.entrySet()) {
final ContainmentType dequeContainmentType = dequeEntry.getKey();
final Deque<InfoVertex<T, C>> deque = dequeEntry.getValue();
while (!deque.isEmpty()) {
final InfoVertex<T, C> sourceVertex = deque.removeFirst();
final ContainmentType currentSourceContainmentType = getInfoVertexContainmentType(sourceVertex);
final ContainmentType sourceContainmentType = dequeContainmentType
.combineWith(currentSourceContainmentType);
if (currentSourceContainmentType == null
|| currentSourceContainmentType
.compareTo(sourceContainmentType) > 0) {
if (currentSourceContainmentType != null
&& !currentSourceContainmentType.isIncluded()) {
logger.warn(MessageFormat
.format("The vertex [{0}] was excluded with the containment type [{1}], but it must be included with containment type [{2}], otherwise mappings will not be consistent.",
sourceVertex,
currentSourceContainmentType,
sourceContainmentType));
} else {
logger.trace(MessageFormat
.format("Including the vertex [{0}] with the containment type [{1}].",
sourceVertex, dequeContainmentType));
}
setInfoVertexContainmentType(sourceVertex,
sourceContainmentType);
final Set<DependencyEdge> edges = graph
.outgoingEdgesOf(sourceVertex);
for (DependencyEdge edge : edges) {
final InfoVertex<T, C> targetVertex = graph
.getEdgeTarget(edge);
final DependencyType dependencyType = edge.getType();
final ContainmentType targetContainmentType = dependencyType
.combineWith(sourceContainmentType);
if (targetContainmentType != null) {
final Deque<InfoVertex<T, C>> targetDeque = deques
.get(targetContainmentType);
if (targetDeque != null) {
logger.trace(MessageFormat
.format("Queueing the inclusion of the vertex [{0}] with the containment type [{1}].",
targetVertex,
targetContainmentType));
targetDeque.add(targetVertex);
}
}
}
} else {
logger.trace(MessageFormat
.format("Vertex [{0}] is already included with the containment type [{1}].",
sourceVertex, currentSourceContainmentType));
}
}
}
}
示例14: main
import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
public static void main(String[] args) {
// create a graph based on URL objects
DirectedGraph<URL, DefaultEdge> hrefGraph = createHrefGraph();
// note directed edges are printed as: (<v1>,<v2>)
System.out.println(hrefGraph.toString());
for (URL url : hrefGraph.vertexSet()) {
Set<DefaultEdge> edgesOutVertex = hrefGraph.outgoingEdgesOf(url);
System.out.println("[vertex]" + url + " -- out edge :" + edgesOutVertex.size());
}
}