private void walk(final ModuleFactory node, final List<ModuleFactory> res) { if (!res.contains(node)) { for (final DepLink l : this.graph.outgoingEdgesOf(node)) { this.walk(l.getTarget(), res); } res.add(node); } }
public final Map<Object, ModuleFactory> getDependencies( final ModuleFactory f, final NodeState state) { final Set<DepLink> outgoingEdges = this.graph.outgoingEdgesOf(f); final Map<Object, ModuleFactory> res = new HashMap<Object, ModuleFactory>(outgoingEdges.size()); for (final DepLink l : outgoingEdges) { if (state == null || getState(l.getTarget()) == state) res.put(l.getDepID(), l.getTarget()); } return res; }
private void removeRec(ModuleFactory f) { this.checkFrozen(); this.solved.remove(f); this.solving.remove(f); // copy live view final Set<DepLink> incomingEdges = new HashSet<DepLink>(this.graph.incomingEdgesOf(f)); this.graph.removeVertex(f); for (final DepLink l : incomingEdges) { final ModuleFactory src = l.getSource(); assert l.getTarget() == f; this.removeRec(src); } }
/** Build set of dependencies for the given module, grouped under a fake root container */ public DepLink build(SModule module) { DepLink rv = new DepLink(module.getModuleReference(), DependencyUtil.Role.None, null); List<DepLink> queue = ListSequence.fromList(new LinkedList<DepLink>()); ListSequence.fromList(queue).addElement(rv); Map<Dependency, DepLink> visited = MapSequence.fromMap(new HashMap<Dependency, DepLink>()); while (ListSequence.fromList(queue).isNotEmpty()) { DepLink e = ListSequence.fromList(queue).removeElementAt(0); List<DepLink> dependencies = dependencies(e.role, e.module); for (DepLink d : ListSequence.fromList(dependencies)) { d.myParent = e; ListSequence.fromList(e.children()).addElement(d); Dependency key = d.getRoleModuleKey(); if (MapSequence.fromMap(visited).containsKey(key)) { d.setReused(MapSequence.fromMap(visited).get(key)); } else { MapSequence.fromMap(visited).put(key, d); ListSequence.fromList(queue).addElement(d); } } } return rv; }
public ModuleFactory getDependency(final ModuleFactory f, final Object id) { for (final DepLink l : this.graph.outgoingEdgesOf(f)) { if (l.getDepID().equals(id)) return l.getTarget(); } return null; }