Java Code Examples for org.jgrapht.DirectedGraph#outgoingEdgesOf()
The following examples show how to use
org.jgrapht.DirectedGraph#outgoingEdgesOf() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScheduleTGDStrata.java From Llunatic with GNU General Public License v3.0 | 5 votes |
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(); } }
Example 2
Source File: ScheduleEGDStrata.java From Llunatic with GNU General Public License v3.0 | 5 votes |
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(); } }
Example 3
Source File: Mapping.java From jsonix-schema-compiler with BSD 2-Clause "Simplified" License | 5 votes |
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(); }
Example 4
Source File: MasterGraph.java From furnace with Eclipse Public License 1.0 | 5 votes |
public boolean isSubtreeEquivalent(AddonVertex localVertex, DirectedGraph<AddonVertex, AddonDependencyEdge> otherGraph, AddonVertex otherVertex) { Set<AddonDependencyEdge> otherOutgoing; otherOutgoing = otherGraph.outgoingEdgesOf(otherVertex); Set<AddonDependencyEdge> localOutgoing = graph.outgoingEdgesOf(localVertex); if (otherOutgoing.size() == localOutgoing.size()) { for (AddonDependencyEdge otherEdge : otherOutgoing) { AddonVertex otherTarget = graph.getEdgeTarget(otherEdge); Set<AddonVertex> localCandidates = getVertices(otherTarget.getName(), otherTarget.getVersion()); boolean found = false; if (!localCandidates.isEmpty()) { for (AddonVertex candidate : localCandidates) { AddonDependencyEdge localEdge = graph.getEdge(localVertex, candidate); if (localEdge != null && isSubtreeEquivalent(candidate, otherGraph, otherTarget)) { found = true; break; } } } if (!found) return false; } return true; } return false; }
Example 5
Source File: TridentUtils.java From jstorm with Apache License 2.0 | 5 votes |
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; }
Example 6
Source File: GraphUtils.java From Nicobar with Apache License 2.0 | 5 votes |
/** * Fetch all of the dependencies of the given source vertex * @return mutable snapshot of the target vertices of all outgoing edges */ public static <V> Set<V> getOutgoingVertices(DirectedGraph<V, DefaultEdge> graph, V source) { Set<DefaultEdge> edges = graph.outgoingEdgesOf(source); Set<V> targets = new LinkedHashSet<V>(); for (DefaultEdge edge : edges) { targets.add(graph.getEdgeTarget(edge)); } return targets; }
Example 7
Source File: Mapping.java From jsonix-schema-compiler with BSD 2-Clause "Simplified" License | 4 votes |
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)); } } } }