Program: 76242
Project: 76242
Buggy source:
/** 
 * Return a new instance of a BasicGraph with the given semantic object.
 */
public Graph createGraph(Object semanticObject){
  Graph g=new BasicGraph();
  g.setSemanticObject(semanticObject);
  if (semanticObject instanceof CompositeEntity) {
    CompositeEntity toplevel=(CompositeEntity)semanticObject;
    Iterator entities=toplevel.entityList().iterator();
    while (entities.hasNext()) {
      Entity entity=(Entity)entities.next();
      Icon icon=(Icon)entity.getAttribute("String_Node_Str");
      if (icon == null) {
        try {
          icon=new EditorIcon(entity);
        }
 catch (        Exception e) {
          throw new InternalErrorException("String_Node_Str" + "String_Node_Str" + e.getMessage());
        }
      }
      addNode(createCompositeNode(icon),g);
    }
    Iterator relations=toplevel.relationList().iterator();
    while (relations.hasNext()) {
      Relation relation=(Relation)relations.next();
      Iterator attributes=relation.attributeList().iterator();
      Node rootVertex=null;
      while (attributes.hasNext()) {
        Attribute a=(Attribute)attributes.next();
        if (a instanceof Vertex) {
          Node n=createNode(a);
          if (((Vertex)a).getLinkedVertex() == null) {
            rootVertex=n;
          }
          addNode(n,g);
        }
      }
      int count=0;
      Enumeration links=relation.linkedPorts();
      while (links.hasMoreElements()) {
        links.nextElement();
        count++;
      }
      if (rootVertex == null && count == 2) {
        links=relation.linkedPorts();
        Port port1=(Port)links.nextElement();
        Port port2=(Port)links.nextElement();
        Node node1=_findNode(g,port1);
        Node node2=_findNode(g,port2);
        Edge newEdge=createEdge(null);
        super.setEdgeHead(newEdge,node1);
        super.setEdgeTail(newEdge,node2);
      }
 else {
        if (rootVertex == null) {
          try {
            Vertex v=new Vertex(relation,relation.uniqueName("String_Node_Str"));
            rootVertex=createNode(v);
          }
 catch (          Exception e) {
            throw new InternalErrorException("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ e.getMessage());
          }
          addNode(rootVertex,g);
        }
        links=relation.linkedPorts();
        while (links.hasMoreElements()) {
          Port port=(Port)links.nextElement();
          Node foundNode=_findNode(g,port);
          Edge newEdge=createEdge(null);
          super.setEdgeHead(newEdge,foundNode);
          super.setEdgeTail(newEdge,rootVertex);
        }
      }
    }
  }
  return g;
}

Fixed version (ground truth):
/** 
 * Return a new instance of a BasicGraph with the given semantic object.
 */
public Graph createGraph(Object semanticObject){
  Graph g=new BasicGraph();
  g.setSemanticObject(semanticObject);
  if (semanticObject instanceof CompositeEntity) {
    CompositeEntity toplevel=(CompositeEntity)semanticObject;
    Iterator entities=toplevel.entityList().iterator();
    while (entities.hasNext()) {
      Entity entity=(Entity)entities.next();
      Icon icon=(Icon)entity.getAttribute("String_Node_Str");
      if (icon == null) {
        try {
          icon=new EditorIcon(entity);
        }
 catch (        Exception e) {
          throw new InternalErrorException("String_Node_Str" + "String_Node_Str" + e.getMessage());
        }
      }
      addNode(createCompositeNode(icon),g);
    }
    Iterator relations=toplevel.relationList().iterator();
    while (relations.hasNext()) {
      Relation relation=(Relation)relations.next();
      Iterator attributes=relation.attributeList().iterator();
      Node rootVertex=null;
      while (attributes.hasNext()) {
        Attribute a=(Attribute)attributes.next();
        if (a instanceof Vertex) {
          Node n=createNode(a);
          if (((Vertex)a).getLinkedVertex() == null) {
            rootVertex=n;
          }
          addNode(n,g);
        }
      }
      int count=0;
      Enumeration links=relation.linkedPorts();
      while (links.hasMoreElements()) {
        links.nextElement();
        count++;
      }
      if (rootVertex == null && count == 2) {
        links=relation.linkedPorts();
        Port port1=(Port)links.nextElement();
        Port port2=(Port)links.nextElement();
        Node node1=_findNode(g,port1);
        Node node2=_findNode(g,port2);
        Edge newEdge=createEdge(relation);
        super.setEdgeHead(newEdge,node1);
        super.setEdgeTail(newEdge,node2);
      }
 else {
        if (rootVertex == null) {
          try {
            Vertex v=new Vertex(relation,relation.uniqueName("String_Node_Str"));
            rootVertex=createNode(v);
          }
 catch (          Exception e) {
            throw new InternalErrorException("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ e.getMessage());
          }
          addNode(rootVertex,g);
        }
        links=relation.linkedPorts();
        while (links.hasMoreElements()) {
          Port port=(Port)links.nextElement();
          Node foundNode=_findNode(g,port);
          Edge newEdge=createEdge(null);
          super.setEdgeHead(newEdge,foundNode);
          super.setEdgeTail(newEdge,rootVertex);
        }
      }
    }
  }
  return g;
}