def WriteGraph(edges):
 files = collections.defaultdict(list)
 for (src, dst) in edges.items():
  (build_file, target_name, toolset) = ParseTarget(src)
  files[build_file].append(src)
 print 'digraph D {'
 print '  fontsize=8'
 print '  node [fontsize=8]'
 for (filename, targets) in files.items():
  if (len(targets) == 1):
   target = targets[0]
   (build_file, target_name, toolset) = ParseTarget(target)
   print ('  "%s" [shape=box, label="%s\\n%s"]' % (target, filename, target_name))
  else:
   print ('  subgraph "cluster_%s" {' % filename)
   print ('    label = "%s"' % filename)
   for target in targets:
    (build_file, target_name, toolset) = ParseTarget(target)
    print ('    "%s" [label="%s"]' % (target, target_name))
   print '  }'
 for (src, dsts) in edges.items():
  for dst in dsts:
   print ('  "%s" -> "%s"' % (src, dst))
 print '}'

def WriteGraph ( edges ) : files = collections . defaultdict ( list ) for ( src , dst ) in edges . items ( ) : ( build_file , target_name , toolset ) = ParseTarget ( src ) files [ build_file ] . append ( src ) print 'digraph D {' print '  fontsize=8' print '  node [fontsize=8]' for ( filename , targets ) in files . items ( ) : if ( len ( targets ) == 1 ) : target = targets [ 0 ] ( build_file , target_name , toolset ) = ParseTarget ( target ) print ( '  "%s" [shape=box, label="%s\\n%s"]' % ( target , filename , target_name ) ) else : print ( '  subgraph "cluster_%s" {' % filename ) print ( '    label = "%s"' % filename ) for target in targets : ( build_file , target_name , toolset ) = ParseTarget ( target ) print ( '    "%s" [label="%s"]' % ( target , target_name ) ) print '  }' for ( src , dsts ) in edges . items ( ) : for dst in dsts : print ( '  "%s" -> "%s"' % ( src , dst ) ) print '}'
print a graphviz graph to stdout .