Program: 75434
Project: 75434
Buggy source:
/** 
 * Construct a directed graph with the nodes representing input and output ports, and directed edges representing dependencies.   The directed graph is returned.
 */
protected void _constructDirectedGraph() throws IllegalActionException, NameDuplicationException {
  Actor container=(Actor)getContainer();
  _dg=new DirectedGraph();
  Iterator inputs=container.inputPortList().listIterator();
  while (inputs.hasNext()) {
    _dg.addNodeWeight(inputs.next());
  }
  Iterator outputs=container.outputPortList().listIterator();
  while (outputs.hasNext()) {
    _dg.addNodeWeight(outputs.next());
  }
  Iterator embeddedActors=((CompositeActor)container).deepEntityList().iterator();
  while (embeddedActors.hasNext()) {
    Actor embeddedActor=(Actor)embeddedActors.next();
    Iterator inputsInside=embeddedActor.inputPortList().listIterator();
    while (inputsInside.hasNext()) {
      _dg.addNodeWeight(inputsInside.next());
    }
    Iterator outputsInside=embeddedActor.outputPortList().listIterator();
    while (outputsInside.hasNext()) {
      _dg.addNodeWeight(outputsInside.next());
    }
  }
  embeddedActors=((CompositeActor)container).deepEntityList().iterator();
  while (embeddedActors.hasNext()) {
    Actor embeddedActor=(Actor)embeddedActors.next();
    IODependence ioDependence=(IODependence)((NamedObj)embeddedActor).getAttribute("String_Node_Str",IODependence.class);
    if (ioDependence == null) {
      if (embeddedActor instanceof AtomicActor) {
        ioDependence=new IODependenceOfAtomicActor((Entity)embeddedActor,"String_Node_Str");
      }
 else {
        ioDependence=new IODependenceOfCompositeActor((Entity)embeddedActor,"String_Node_Str");
      }
    }
    Iterator inputPorts=embeddedActor.inputPortList().iterator();
    while (inputPorts.hasNext()) {
      IOPort inputPort=(IOPort)inputPorts.next();
      Set notDirectlyDependentOutputPorts=ioDependence.getNotDirectlyDependentPorts(inputPort);
      Iterator outputPorts=embeddedActor.outputPortList().iterator();
      while (outputPorts.hasNext()) {
        IOPort outputPort=(IOPort)outputPorts.next();
        if (!notDirectlyDependentOutputPorts.contains(outputPort)) {
          _dg.addEdge(inputPort,outputPort);
        }
      }
    }
    Iterator successors=embeddedActor.outputPortList().iterator();
    while (successors.hasNext()) {
      IOPort outPort=(IOPort)successors.next();
      Iterator inPortIterator=outPort.sinkPortList().iterator();
      while (inPortIterator.hasNext()) {
        _dg.addEdge(outPort,inPortIterator.next());
      }
    }
  }
  inputs=container.inputPortList().listIterator();
  while (inputs.hasNext()) {
    IOPort inputPort=(IOPort)inputs.next();
    Iterator inPortIterator=inputPort.insideSinkPortList().iterator();
    while (inPortIterator.hasNext()) {
      _dg.addEdge(inputPort,inPortIterator.next());
    }
  }
}

Fixed version (ground truth):
/** 
 * Construct a directed graph with the nodes representing input and output ports, and directed edges representing dependencies.   The directed graph is returned.
 */
protected void _constructDirectedGraph() throws IllegalActionException, NameDuplicationException {
  Actor container=(Actor)getContainer();
  _dg=new DirectedGraph();
  Iterator inputs=container.inputPortList().listIterator();
  while (inputs.hasNext()) {
    _dg.addNodeWeight(inputs.next());
  }
  Iterator outputs=container.outputPortList().listIterator();
  while (outputs.hasNext()) {
    _dg.addNodeWeight(outputs.next());
  }
  Iterator embeddedActors=((CompositeActor)container).deepEntityList().iterator();
  while (embeddedActors.hasNext()) {
    Actor embeddedActor=(Actor)embeddedActors.next();
    Iterator inputsInside=embeddedActor.inputPortList().listIterator();
    while (inputsInside.hasNext()) {
      _dg.addNodeWeight(inputsInside.next());
    }
    Iterator outputsInside=embeddedActor.outputPortList().listIterator();
    while (outputsInside.hasNext()) {
      _dg.addNodeWeight(outputsInside.next());
    }
  }
  embeddedActors=((CompositeActor)container).deepEntityList().iterator();
  while (embeddedActors.hasNext()) {
    Actor embeddedActor=(Actor)embeddedActors.next();
    IODependence ioDependence=(IODependence)((NamedObj)embeddedActor).getAttribute("String_Node_Str",IODependence.class);
    if (ioDependence == null) {
      if (embeddedActor instanceof AtomicActor) {
        ioDependence=new IODependenceOfAtomicActor((Entity)embeddedActor,"String_Node_Str");
      }
 else       if (embeddedActor instanceof CompositeActor) {
        ioDependence=new IODependenceOfCompositeActor((Entity)embeddedActor,"String_Node_Str");
      }
 else {
        return;
      }
    }
    Iterator inputPorts=embeddedActor.inputPortList().iterator();
    while (inputPorts.hasNext()) {
      IOPort inputPort=(IOPort)inputPorts.next();
      Set notDirectlyDependentOutputPorts=ioDependence.getNotDirectlyDependentPorts(inputPort);
      Iterator outputPorts=embeddedActor.outputPortList().iterator();
      while (outputPorts.hasNext()) {
        IOPort outputPort=(IOPort)outputPorts.next();
        if (!notDirectlyDependentOutputPorts.contains(outputPort)) {
          _dg.addEdge(inputPort,outputPort);
        }
      }
    }
    Iterator successors=embeddedActor.outputPortList().iterator();
    while (successors.hasNext()) {
      IOPort outPort=(IOPort)successors.next();
      Iterator inPortIterator=outPort.sinkPortList().iterator();
      while (inPortIterator.hasNext()) {
        _dg.addEdge(outPort,inPortIterator.next());
      }
    }
  }
  inputs=container.inputPortList().listIterator();
  while (inputs.hasNext()) {
    IOPort inputPort=(IOPort)inputs.next();
    Iterator inPortIterator=inputPort.insideSinkPortList().iterator();
    while (inPortIterator.hasNext()) {
      _dg.addEdge(inputPort,inPortIterator.next());
    }
  }
}