Turning `make --debug=b` into a graph

Hello,

My lack of computer science training
is showing: It seems like turning the
sample output shown after my signature
into a Graphviz dot graph should be easy,
but I can't find an elegant way of doing it.

Can someone lend an algorithm?

Foundation:

sudo gem install rgl

require 'rgl/adjacency'
require 'rgl/dot'

dg = RGL::DirectedAdjacencyGraph.new
dg.add_edge( from, to )
dg.write_to_graphic_file

Thanks,

···

--
Bil
http://fun3d.larc.nasa.gov

main
  fun3d_res_flow
    kinddefs
    grid
      bc_types
        info
        allocate
        lmpi
          interp_defs
      element_defs
        code_status
      adjoint_switches
      aeroelastic
      array_check
    solution
      force
        fluid
        ivals
        refgeom
        utilities
          system_extensions
        twod
        runge
      comprow
      solution_io_helpers
      io
        bc_util
        grid_motion
          move
            gmres
              blas
            grid_metrics
              sort
            character_function
          distance_function
            projection_distance
            nearest_neighbor
            search
          rotor
          timeacc_coeffs
          flux_util
      input_sanity
      command_line_parser
        design
          design_types
          crinkle_cut
            interpolate
              project
          design_io_helpers
        f2kcli
        debug_jacobian
        noninertial
      thermo
    move_module_mixed
    flux
      bc
        bc_wallfun
        reconstruction
          fieldview
            fvpars
        init
          timeacc
            turb_gen
          spalart_constants
          kw_sst_constants
          UPFD_Hefss
            user_prescribed_data
      bc_inviscid
      flux_perfgas
      source
      flux_incomp
      source_gen
        chemical_kinetics
          physics_types
          allocate_gen
          shared_gas_variables
          thermodynamics
            equilibrium_air
        thermal_relaxation
      thermo_gen
      bc_gen
        transport_property
        flux_gengas
      reconstruct_gen
      elliptic
        fill_jacobian
          jacobian
          spalart
            spalart_mix
            spalart_tet
              turb_util
  eqn_groups
    construct_lines
  init_gen
    io_gen
  adapt_spring
  timing
  multigrid
    complex
    update
      turb_model
        kw_sst
          timestep
        survey_matrix
        point_solve
          monitor
        line_solve
        linearsolve
          lu
          ilu
      timestep_gen
      fill_jacobian_gen
        jacobian_gen
      dgmres
        preconditioner
      overset
      debug
  check_jacobian
  force_driver
    force_gen
      mixed_element
        puns3d_io
          global_grid
          split_element
          rad_embed
            global_soln
            edge_swap
            finite_element_interp
            linear_algebra
    force_flux
  adjust_alpha
  grid_helper

RGL looks like too much typing, so I used lib/graph.rb from ZenHacks:

$ ruby make_graph.rb data.txt > kleb.dot
$ open kleb.dot
[ All sizes | `make --debug=b` expressed as a graph | Flickr - Photo Sharing! you can download the full-size 5498x735 px version there as well. ]
$ cat make_graph.rb
require 'graph'

data = ARGF.readlines

graph = Graph.new
last_indent = 1
parents = [data.shift.strip]
last_node = nil

data.each do |line|
   line =~ /^(\s+)(.*)/

   node = $2
   indent = $1.length.to_i / 2 - 1

   parents[indent] = last_node if last_indent < indent
   graph[parents[indent]] << node

   last_indent = indent
   last_node = node
end

puts graph.to_s

···

On Nov 4, 2005, at 1:27 PM, Bil.Kleb@gmail.com wrote:

Hello,

My lack of computer science training
is showing: It seems like turning the
sample output shown after my signature
into a Graphviz dot graph should be easy,
but I can't find an elegant way of doing it.

Can someone lend an algorithm?

Foundation:

sudo gem install rgl

require 'rgl/adjacency'
require 'rgl/dot'

dg = RGL::DirectedAdjacencyGraph.new
dg.add_edge( from, to )
dg.write_to_graphic_file

--
Eric Hodel - drbrain@segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

Sweet.

And I especially like the low overhead graph utility.

Thanks,

···

--
Bil
http://fun3d.larc.nasa.gov