public String toString(SootMethod method,Block start){
  Map<Block,Integer> blockNumbers=new HashMap<Block,Integer>();
  StringBuilder sb=new StringBuilder("digraph " + method.getName() + "CFG {\n");
  int bIdx=0;
  int instOff=0;
  for (  Block b : this) {
    blockNumbers.put(b,bIdx);
    sb.append("  bb");
    sb.append(bIdx);
    sb.append(" [shape=none, margin=0, label=<\n");
    if (b.equals(start))     sb.append("    <table bgcolor=\"#FF6666\" border=\"0\" cellborder=\"1\" cellspacing=\"0\" cellpadding=\"4\">\n");
 else     sb.append("    <table border=\"0\" cellborder=\"1\" cellspacing=\"0\" cellpadding=\"4\">\n");
    int idx=b.getIndexInMethod();
    if (heads.contains(b)) {
      sb.append("      <tr><td align=\"center\">START</td></tr>");
    }
 else     if (tails.contains(b)) {
      sb.append("      <tr><td align=\"center\">END</td></tr>");
    }
 else {
      for (      Unit unit : b) {
        sb.append("      <tr><td align=\"left\">");
        sb.append(idx + instOff);
        sb.append("</td><td align=\"left\">");
        sb.append(StringEscapeUtils.escapeHtml4(unit.toString()));
        sb.append("</td></tr>\n");
        instOff++;
      }
      instOff--;
    }
    sb.append("    </table>>];\n");
    bIdx++;
  }
  for (  Block b : this) {
    int bFrom=blockNumbers.containsKey(b) ? blockNumbers.get(b) : blockNumbers.size();
    for (    Block succ : getSuccsOf(b)) {
      int bTo=blockNumbers.containsKey(succ) ? blockNumbers.get(succ) : blockNumbers.size();
      sb.append("  bb");
      sb.append(bFrom);
      sb.append(" -> bb");
      sb.append(bTo);
      sb.append(";\n");
    }
  }
  sb.append("}");
  return sb.toString();
}

public String toString ( SootMethod method , Block start ) { Map < Block , Integer > blockNumbers = new HashMap < Block , Integer > ( ) ; StringBuilder sb = new StringBuilder ( "digraph " + method . getName ( ) + "CFG {\n" ) ; int bIdx = 0 ; int instOff = 0 ; for ( Block b : this ) { blockNumbers . put ( b , bIdx ) ; sb . append ( "  bb" ) ; sb . append ( bIdx ) ; sb . append ( " [shape=none, margin=0, label=<\n" ) ; if ( b . equals ( start ) ) sb . append ( "    <table bgcolor=\"#FF6666\" border=\"0\" cellborder=\"1\" cellspacing=\"0\" cellpadding=\"4\">\n" ) ; else sb . append ( "    <table border=\"0\" cellborder=\"1\" cellspacing=\"0\" cellpadding=\"4\">\n" ) ; int idx = b . getIndexInMethod ( ) ; if ( heads . contains ( b ) ) { sb . append ( "      <tr><td align=\"center\">START</td></tr>" ) ; } else if ( tails . contains ( b ) ) { sb . append ( "      <tr><td align=\"center\">END</td></tr>" ) ; } else { for ( Unit unit : b ) { sb . append ( "      <tr><td align=\"left\">" ) ; sb . append ( idx + instOff ) ; sb . append ( "</td><td align=\"left\">" ) ; sb . append ( StringEscapeUtils . escapeHtml4 ( unit . toString ( ) ) ) ; sb . append ( "</td></tr>\n" ) ; instOff ++ ; } instOff -- ; } sb . append ( "    </table>>];\n" ) ; bIdx ++ ; } for ( Block b : this ) { int bFrom = blockNumbers . containsKey ( b ) ? blockNumbers . get ( b ) : blockNumbers . size ( ) ; for ( Block succ : getSuccsOf ( b ) ) { int bTo = blockNumbers . containsKey ( succ ) ? blockNumbers . get ( succ ) : blockNumbers . size ( ) ; sb . append ( "  bb" ) ; sb . append ( bFrom ) ; sb . append ( " -> bb" ) ; sb . append ( bTo ) ; sb . append ( ";\n" ) ; } } sb . append ( "}" ) ; return sb . toString ( ) ; }
generate graphviz dot output on method and marking the start block in red .
