當前位置: 首頁>>代碼示例>>Java>>正文


Java DirectedGraph.outgoingEdgesOf方法代碼示例

本文整理匯總了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;
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:18,代碼來源:DepcyGraphView.java

示例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);
}
 
開發者ID:Cooperate-Project,項目名稱:CooperateModelingEnvironment,代碼行數:21,代碼來源:DerivedStateProcessor.java

示例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;
}
 
開發者ID:therelaxist,項目名稱:spring-usc,代碼行數:17,代碼來源:GraphUtil.java

示例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;
}
 
開發者ID:j123b567,項目名稱:stack-usage,代碼行數:23,代碼來源:CallGraph.java

示例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();
    }
}
 
開發者ID:DocGerd,項目名稱:DalvikSSA,代碼行數:37,代碼來源:WriteGraphToDot.java

示例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;
}
 
開發者ID:zhangjunfang,項目名稱:jstorm-0.9.6.3-,代碼行數:9,代碼來源:TridentUtils.java

示例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());
}
 
開發者ID:Kelleth,項目名稱:age3-nanorobots,代碼行數:10,代碼來源:DefaultTopologyService.java

示例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);
}
 
開發者ID:Kelleth,項目名稱:age3-nanorobots,代碼行數:29,代碼來源:RingTopologyProcessorTest.java

示例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();
    }
}
 
開發者ID:donatellosantoro,項目名稱:Llunatic,代碼行數:16,代碼來源:ScheduleTGDStrata.java

示例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();
    }
}
 
開發者ID:donatellosantoro,項目名稱:Llunatic,代碼行數:16,代碼來源:ScheduleEGDStrata.java

示例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;
        }
    }
}
 
開發者ID:j123b567,項目名稱:stack-usage,代碼行數:34,代碼來源:CallGraph.java

示例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();
}
 
開發者ID:highsource,項目名稱:jsonix-schema-compiler,代碼行數:34,代碼來源:Mapping.java

示例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));
			}
		}
	}
}
 
開發者ID:highsource,項目名稱:jsonix-schema-compiler,代碼行數:78,代碼來源:Mapping.java

示例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());
		}

	}
 
開發者ID:y12studio,項目名稱:bkbc-premature,代碼行數:16,代碼來源:HelloJgraphT.java


注:本文中的org.jgrapht.DirectedGraph.outgoingEdgesOf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。