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


Java DirectedGraph.getEdgeTarget方法代碼示例

本文整理匯總了Java中org.jgrapht.DirectedGraph.getEdgeTarget方法的典型用法代碼示例。如果您正苦於以下問題:Java DirectedGraph.getEdgeTarget方法的具體用法?Java DirectedGraph.getEdgeTarget怎麽用?Java DirectedGraph.getEdgeTarget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jgrapht.DirectedGraph的用法示例。


在下文中一共展示了DirectedGraph.getEdgeTarget方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例3: shortestCycle

import org.jgrapht.DirectedGraph; //導入方法依賴的package包/類
private static List<String> shortestCycle(DirectedGraph<String, DefaultEdge> graph)
{
    FloydWarshallShortestPaths<String, DefaultEdge> floyd = new FloydWarshallShortestPaths<>(graph);
    int minDistance = Integer.MAX_VALUE;
    String minSource = null;
    String minDestination = null;
    for (DefaultEdge edge : graph.edgeSet()) {
        String src = graph.getEdgeSource(edge);
        String dst = graph.getEdgeTarget(edge);
        int dist = (int) Math.round(floyd.shortestDistance(dst, src)); // from dst to src
        if (dist < 0) {
            continue;
        }
        if (dist < minDistance) {
            minDistance = dist;
            minSource = src;
            minDestination = dst;
        }
    }
    if (minSource == null) {
        return null;
    }
    GraphPath<String, DefaultEdge> shortestPath = floyd.getShortestPath(minDestination, minSource);
    List<String> pathVertexList = Graphs.getPathVertexList(shortestPath);
    // note: pathVertexList will be [a, a] instead of [a] when the shortest path is a loop edge
    if (!Objects.equals(shortestPath.getStartVertex(), shortestPath.getEndVertex())) {
        pathVertexList.add(pathVertexList.get(0));
    }
    return pathVertexList;
}
 
開發者ID:y-lan,項目名稱:presto,代碼行數:31,代碼來源:SqlQueryQueueManager.java

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: cloneGraph

import org.jgrapht.DirectedGraph; //導入方法依賴的package包/類
private static DirectedGraph<FunctionVertex, CallEdge> cloneGraph(DirectedGraph<FunctionVertex, CallEdge> g) {
    DirectedGraph<FunctionVertex, CallEdge> result;
    result = new DefaultDirectedGraph<>(CallEdge.class);

    List<FunctionVertex> list = new ArrayList<>();

    for (FunctionVertex v : g.vertexSet()) {
        FunctionVertex v2 = new FunctionVertex();
        v2.clone(v);
        list.add(v2);
        result.addVertex(v2);
    }

    list.indexOf(g);
    FunctionVertex src;
    FunctionVertex dst;
    for (CallEdge e : g.edgeSet()) {
        src = g.getEdgeSource(e);
        dst = g.getEdgeTarget(e);

        /* get clonned vertex */
        src = list.get(list.indexOf(src));
        dst = list.get(list.indexOf(dst));

        result.addEdge(src, dst, new CallEdge(e.type));
    }

    return result;
}
 
開發者ID:j123b567,項目名稱:stack-usage,代碼行數:30,代碼來源:CallGraph.java

示例9: 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

示例10: 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


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