Program: 74399
Project: 74399
Buggy source:
public int generateCode(StringBuffer code) throws KernelException {
  if (action.getExpression().equals("String_Node_Str")) {
    transformGraph();
    return 0;
  }
  if (action.getExpression().equals("String_Node_Str")) {
    if (_generated == false) {
      throw new IllegalActionException(this,(Throwable)null,"String_Node_Str");
    }
    transformGraph();
    return 0;
  }
  _reset();
  _codeFileName=_writeCode(code);
  StringBuffer codeBuffer=new StringBuffer();
  CompositeEntity compositeActor=(CompositeEntity)getContainer();
  for (  Actor actor : (List<Actor>)compositeActor.deepEntityList()) {
    if (actor instanceof Actor) {
      _numVertices++;
      _HashActorKey.put(actor,_numVertices);
      _HashNumberKey.put(_numVertices,actor);
    }
  }
  code.append(_numVertices + "String_Node_Str");
  for (  Actor actor : (List<Actor>)compositeActor.deepEntityList()) {
    int actorId=(Integer)_HashActorKey.get(actor);
    codeBuffer.append(actorId + "String_Node_Str");
    codeBuffer.append(_getVertexWeight(actor) + "String_Node_Str");
    for (    TypedIOPort inputPort : (List<TypedIOPort>)actor.inputPortList()) {
      for (      TypedIOPort sourcePort : (List<TypedIOPort>)inputPort.sourcePortList()) {
        Actor sourceActor=(Actor)sourcePort.getContainer();
        int outInt=(Integer)_HashActorKey.get(sourceActor);
        codeBuffer.append(outInt + "String_Node_Str");
        for (        Relation relation : (List<Relation>)inputPort.linkedRelationList()) {
          List portList=relation.linkedPortList(inputPort);
          Iterator portIt=(Iterator)portList.listIterator();
          boolean foundFlag=false;
          while (foundFlag == false && portIt.hasNext()) {
            TypedIOPort sinkPort=(TypedIOPort)portIt.next();
            if (!sinkPort.isOpaque()) {
              if (sinkPort.isOutput()) {
                portList.addAll(sinkPort.deepInsidePortList());
              }
 else               if (sinkPort.isInput()) {
                portList.addAll(sinkPort.sourcePortList());
              }
              portList.remove(sinkPort);
              portIt=(Iterator)portList.listIterator();
            }
 else             if (sinkPort.equals(sourcePort)) {
              codeBuffer.append(_getEdgeWeight(relation) + "String_Node_Str");
              foundFlag=true;
            }
          }
        }
      }
    }
    for (    TypedIOPort outputPort : (List<TypedIOPort>)actor.outputPortList()) {
      for (      TypedIOPort sinkPort : (List<TypedIOPort>)outputPort.sinkPortList()) {
        Actor tempActor=(Actor)sinkPort.getContainer();
        int inInt=(Integer)_HashActorKey.get(tempActor);
        codeBuffer.append(inInt + "String_Node_Str");
        for (        Relation relation : (List<Relation>)outputPort.linkedRelationList()) {
          List portList=relation.linkedPortList(outputPort);
          Iterator portIt=(Iterator)portList.listIterator();
          boolean foundFlag=false;
          while (foundFlag == false && portIt.hasNext()) {
            TypedIOPort connInputPort=(TypedIOPort)portIt.next();
            if (!connInputPort.isOpaque()) {
              if (connInputPort.isInput()) {
                portList.addAll(connInputPort.deepInsidePortList());
              }
 else               if (connInputPort.isOutput()) {
                portList.addAll(connInputPort.sinkPortList());
              }
              portList.remove(connInputPort);
              portIt=(Iterator)portList.listIterator();
            }
 else {
              if (connInputPort.equals(sinkPort)) {
                codeBuffer.append(_getEdgeWeight(relation) + "String_Node_Str");
                foundFlag=true;
              }
            }
          }
        }
        _numEdges++;
      }
    }
    codeBuffer.append(_eol);
  }
  code.append(_numEdges + "String_Node_Str" + _eol);
  code.append(codeBuffer);
  _writeChacoInputFile(code.toString());
  _generated=true;
  return 0;
}

Fixed version (ground truth):
public int generateCode(StringBuffer code) throws KernelException {
  if (action.getExpression().equals("String_Node_Str")) {
    transformGraph();
    return 0;
  }
  if (action.getExpression().equals("String_Node_Str")) {
    if (_generated == false) {
      throw new IllegalActionException(this,(Throwable)null,"String_Node_Str");
    }
    transformGraph();
    return 0;
  }
  _reset();
  _codeFileName=_writeCode(code);
  StringBuffer codeBuffer=new StringBuffer();
  CompositeEntity compositeActor=(CompositeEntity)getContainer();
  for (  Actor actor : (List<Actor>)compositeActor.deepEntityList()) {
    if (actor instanceof Actor) {
      _numVertices++;
      _HashActorKey.put(actor,_numVertices);
      _HashNumberKey.put(_numVertices,actor);
    }
  }
  code.append(_numVertices + "String_Node_Str");
  for (  Actor actor : (List<Actor>)compositeActor.deepEntityList()) {
    int actorId=(Integer)_HashActorKey.get(actor);
    codeBuffer.append(actorId + "String_Node_Str");
    codeBuffer.append(_getVertexWeight(actor) + "String_Node_Str");
    for (    TypedIOPort inputPort : (List<TypedIOPort>)actor.inputPortList()) {
      for (      TypedIOPort sourcePort : (List<TypedIOPort>)inputPort.sourcePortList()) {
        Actor sourceActor=(Actor)sourcePort.getContainer();
        int outInt=(Integer)_HashActorKey.get(sourceActor);
        codeBuffer.append(outInt + "String_Node_Str");
        HashMap partialEdgeWeights=new HashMap();
        partialEdgeWeights.put(inputPort,"String_Node_Str");
        LinkedList middlePortList=new LinkedList();
        middlePortList.add(inputPort);
        Iterator middlePortListIt=middlePortList.iterator();
        boolean foundFlag=false;
        while (foundFlag == false && middlePortListIt.hasNext()) {
          TypedIOPort middlePort=(TypedIOPort)middlePortListIt.next();
          if (middlePort.equals(sourcePort)) {
            int temp=Integer.parseInt((String)partialEdgeWeights.get(middlePort));
            codeBuffer.append(Integer.toString(temp) + "String_Node_Str");
            foundFlag=true;
          }
 else {
            for (            Relation relation : (List<Relation>)middlePort.linkedRelationList()) {
              List nextMiddlePortList=relation.linkedPortList(middlePort);
              Iterator nextMiddlePortListIt=(Iterator)nextMiddlePortList.listIterator();
              while (foundFlag == false && nextMiddlePortListIt.hasNext()) {
                TypedIOPort nextMiddlePort=(TypedIOPort)nextMiddlePortListIt.next();
                if (partialEdgeWeights.get(nextMiddlePort) == null) {
                  if (!nextMiddlePort.isOpaque()) {
                    int temp=Integer.parseInt(_getEdgeWeight(relation)) + Integer.parseInt((String)partialEdgeWeights.get(middlePort));
                    partialEdgeWeights.put(nextMiddlePort,Integer.toString(temp));
                    if (nextMiddlePort.isInput()) {
                      middlePortList.add(nextMiddlePort);
                    }
 else {
                      for (                      TypedIOPort hierarchicalConnectedPort : (List<TypedIOPort>)nextMiddlePort.deepInsidePortList()) {
                        for (                        Relation hierarchicalRelation : (List<Relation>)hierarchicalConnectedPort.linkedRelationList()) {
                          for (                          TypedIOPort relationPort : (List<TypedIOPort>)hierarchicalRelation.linkedPortList(hierarchicalConnectedPort)) {
                            if (relationPort.equals(nextMiddlePort)) {
                              int temp2=Integer.parseInt(_getEdgeWeight(hierarchicalRelation)) + Integer.parseInt((String)partialEdgeWeights.get(nextMiddlePort));
                              partialEdgeWeights.put(hierarchicalConnectedPort,Integer.toString(temp2));
                            }
                          }
                        }
                        middlePortList.add(hierarchicalConnectedPort);
                      }
                    }
                    middlePortList.remove(middlePort);
                    middlePortListIt=middlePortList.iterator();
                  }
 else                   if (nextMiddlePort.equals(sourcePort)) {
                    int temp=Integer.parseInt((String)partialEdgeWeights.get(middlePort)) + Integer.parseInt(_getEdgeWeight(relation));
                    codeBuffer.append(Integer.toString(temp) + "String_Node_Str");
                    foundFlag=true;
                  }
                }
              }
            }
          }
        }
      }
    }
    for (    TypedIOPort outputPort : (List<TypedIOPort>)actor.outputPortList()) {
      for (      TypedIOPort sinkPort : (List<TypedIOPort>)outputPort.sinkPortList()) {
        Actor tempActor=(Actor)sinkPort.getContainer();
        int inInt=(Integer)_HashActorKey.get(tempActor);
        codeBuffer.append(inInt + "String_Node_Str");
        HashMap partialEdgeWeights=new HashMap();
        partialEdgeWeights.put(outputPort,"String_Node_Str");
        LinkedList middlePortList=new LinkedList();
        middlePortList.add(outputPort);
        Iterator middlePortListIt=middlePortList.iterator();
        boolean foundFlag=false;
        while (foundFlag == false && middlePortListIt.hasNext()) {
          TypedIOPort middlePort=(TypedIOPort)middlePortListIt.next();
          if (middlePort.equals(sinkPort)) {
            int temp=Integer.parseInt((String)partialEdgeWeights.get(middlePort));
            codeBuffer.append(Integer.toString(temp) + "String_Node_Str");
            foundFlag=true;
          }
 else {
            for (            Relation relation : (List<Relation>)middlePort.linkedRelationList()) {
              List nextMiddlePortList=relation.linkedPortList(middlePort);
              Iterator nextMiddlePortListIt=(Iterator)nextMiddlePortList.listIterator();
              while (foundFlag == false && nextMiddlePortListIt.hasNext()) {
                TypedIOPort nextMiddlePort=(TypedIOPort)nextMiddlePortListIt.next();
                if (partialEdgeWeights.get(nextMiddlePort) == null) {
                  if (!nextMiddlePort.isOpaque()) {
                    int temp=Integer.parseInt(_getEdgeWeight(relation)) + Integer.parseInt((String)partialEdgeWeights.get(middlePort));
                    partialEdgeWeights.put(nextMiddlePort,Integer.toString(temp));
                    if (!nextMiddlePort.isInput()) {
                      middlePortList.add(nextMiddlePort);
                    }
 else {
                      for (                      TypedIOPort hierarchicalConnectedPort : (List<TypedIOPort>)nextMiddlePort.deepInsidePortList()) {
                        for (                        Relation hierarchicalRelation : (List<Relation>)hierarchicalConnectedPort.linkedRelationList()) {
                          for (                          TypedIOPort relationPort : (List<TypedIOPort>)hierarchicalRelation.linkedPortList(hierarchicalConnectedPort)) {
                            if (relationPort.equals(nextMiddlePort)) {
                              int temp2=Integer.parseInt(_getEdgeWeight(hierarchicalRelation)) + Integer.parseInt((String)partialEdgeWeights.get(nextMiddlePort));
                              partialEdgeWeights.put(hierarchicalConnectedPort,Integer.toString(temp2));
                            }
                          }
                        }
                        middlePortList.add(hierarchicalConnectedPort);
                      }
                    }
                    middlePortList.remove(middlePort);
                    middlePortListIt=middlePortList.iterator();
                  }
 else                   if (nextMiddlePort.equals(sinkPort)) {
                    int temp=Integer.parseInt((String)partialEdgeWeights.get(middlePort)) + Integer.parseInt(_getEdgeWeight(relation));
                    codeBuffer.append(Integer.toString(temp) + "String_Node_Str");
                    foundFlag=true;
                  }
                }
              }
            }
          }
        }
        _numEdges++;
      }
    }
    codeBuffer.append(_eol);
  }
  code.append(_numEdges + "String_Node_Str" + _eol);
  code.append(codeBuffer);
  _writeChacoInputFile(code.toString());
  _generated=true;
  return 0;
}