当前位置: 首页>>代码示例>>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;未经允许,请勿转载。