Hacker News new | past | comments | ask | show | jobs | submit login

Yeah when you have requirements around layout graphviz gets a bit hairy. It's still doable with rank directives and invisible nodes, but that's the point where I start to think if I shouldn't do it another way (e.g. in this case I'd probably have done an ascii diagram rendered).

    digraph G {
      rankdir=LR
      node [shape=rectangle]

      // nodes declared in order of horizontal position ("rank")
      exciter
      filter

      subgraph H {
        // nodes at the same horizontal rank
        rank=same
        plus [label="+"]
        // invisible node for layout purposes
        p1 [width=0, height=0, margin=0, label=""]
      }
      subgraph I {
        rank=same
        delay
        nl
      }
      subgraph J {
        rank=same
        filter_ [label="filter"]
        p2 [width=0, height=0, margin=0, label=""]
      }

      out

      exciter -> filter -> plus -> delay -> filter_ -> out
      filter_ -> p2 [arrowhead=none]
      p2 -> nl -> p1 [arrowhead=none]
      p1 -> plus  
    }
Here's the result: http://prntscr.com/n35czl



Nice! Thanks for sharing your graphviz-fu, that's actually not as hairy as I thought it would be, and the result is neat enough. I do remember playing with subgraphs and ranks when testing graphviz, but I gave up before getting this far. I'll try applying those techniques to more complex diagrams, and if I find it workable, I might just switch to that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: