List entities = castContainer.deepEntityList();
Iterator actors = entities.iterator();
int actorCount = entities.size();
while (actors.hasNext()) {
Actor actor = (Actor) actors.next();
dag.addNodeWeight(actor);
}
actors = castContainer.deepEntityList().iterator();
while (actors.hasNext()) {
Actor actor = (Actor) actors.next();
// Find the successors of the actor
Set successors = new HashSet();
Iterator outports = actor.outputPortList().iterator();
while (outports.hasNext()) {
IOPort outPort = (IOPort) outports.next();
Iterator sinkPorts = outPort.sinkPortList().iterator();
while (sinkPorts.hasNext()) {
IOPort sinkPort = (IOPort) sinkPorts.next();
if (sinkPort.isOutput()) {
// Skip this port, since its part of the container
continue;
}
Actor sinkActor = (Actor) sinkPort.getContainer();
successors.add(sinkActor);
}
}
// Add the edge in the DAG
Iterator succeedingActors = successors.iterator();
while (succeedingActors.hasNext()) {
Actor connectedActor = (Actor) succeedingActors.next();
dag.addEdge(actor, connectedActor);
}
}
// NOTE: The following may be a very costly test, which is why