graphs.md (965B)
1 # Graphs 2 This is an example that I've actually used in my lecture notes. 3 Let's say I want to include a diagram, drawn programmatically. 4 First, I include the image: 5 6  7 8 Then I can add the code, folded away in a `details` tag. 9 10 <details> 11 <summary>Graphviz code</summary> 12 13 <!-- :Tangle(dot) first-diagram.dot --> 14 ```dot 15 graph t { 16 a -- b [label="x"] 17 a -- c [label="y"] 18 c -- d [label="y"] 19 c -- e [label="z"] 20 } 21 ``` 22 23 </details> 24 25 Then a second diagram, in the same way. 26 27  28 29 <details> 30 <summary>Graphviz code</summary> 31 32 <!-- :Tangle(dot) second-diagram.dot --> 33 ```dot 34 digraph g { 35 a -> b 36 b -> a 37 } 38 ``` 39 40 </details> 41 42 Now in the markdown document, I just call `:Tangle` in Vim. 43 I close the markdown document window, and run `:windo make`. 44 My ftplugin for Dot files sets makeprg to `dot -Tsvg -O %`, which means the graphs will be simple to generate, and will be made with easily predictable filenames.