Skip to content

Commit

Permalink
Examples do not call dotty
Browse files Browse the repository at this point in the history
- Only create graphic files to better use gitpod
- Add unix history dot file
  • Loading branch information
monora committed Nov 22, 2020
1 parent 2bd7386 commit 6bba969
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 9 deletions.
20 changes: 11 additions & 9 deletions examples/examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def bfs_example(g = cycle(5), start = g.detect { |x| true })
end

# Would like to have GraphXML here
def graph_from_dotfile (file)
def graph_from_dotfile(file)
g = RGL::AdjacencyGraph.new
pattern = /\s*([^\"]+)[\"\s]*--[\"\s]*([^\"\[\;]+)/ # ugly but works
IO.foreach(file) { |line|
Expand All @@ -94,21 +94,23 @@ def graph_from_dotfile (file)
g
end

# ruby -Ilib -r examples/examples.rb -rrgl/dot -e'bfs_example(module_graph,RGL::AdjacencyGraph).dotty'

# ruby -Ilib examples/examples.rb
if $0 == __FILE__
require 'rgl/dot'

dg = RGL::DirectedAdjacencyGraph[1,2, 2,3, 2,4, 4,5, 6,4, 1,6]
dg.dotty
dg.write_to_graphic_file
bfs_example(dg, 1).dotty
bfs_example(graph_from_dotfile('dot/unix.dot'), 'Interdata').dotty({ 'label' => 'Interdata Nachfolger', 'fontsize' => 12 })

# BFS tree from 1 of dg:
bfs_example(dg, 1).write_to_graphic_file('png', 'bfs_example')

# Unix history as a graph:
g = bfs_example(graph_from_dotfile('examples/unix.dot'), 'Interdata')
g.write_to_graphic_file('png', 'unix', { 'label' => 'Interdata Nachfolger', 'fontsize' => 12 })

# Modules included by AdjacencyGraph:
g = module_graph
tree = bfs_example(module_graph, RGL::AdjacencyGraph)
g = g.vertices_filtered_by { |v| tree.has_vertex? v }
g.write_to_graphic_file
g.dotty
g.write_to_graphic_file('png', 'module_graph')
end

53 changes: 53 additions & 0 deletions examples/unix.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* courtesy Ian Darwin and Geoff Collyer, Softquad Inc. */
digraph unix {
size="6,6";
"5th Edition" -> "6th Edition";
"5th Edition" -> "PWB 1.0";
"6th Edition" -> "LSX";
"6th Edition" -> "1 BSD";
"6th Edition" -> "Mini Unix";
"6th Edition" -> "Wollongong";
"6th Edition" -> "Interdata";
"Interdata" -> "Unix/TS 3.0";
"Interdata" -> "PWB 2.0";
"Interdata" -> "7th Edition";
"7th Edition" -> "8th Edition";
"7th Edition" -> "32V";
"7th Edition" -> "V7M";
"7th Edition" -> "Ultrix-11";
"7th Edition" -> "Xenix";
"7th Edition" -> "UniPlus+";
"V7M" -> "Ultrix-11";
"8th Edition" -> "9th Edition";
"1 BSD" -> "2 BSD";
"2 BSD" -> "2.8 BSD";
"2.8 BSD" -> "Ultrix-11";
"2.8 BSD" -> "2.9 BSD";
"32V" -> "3 BSD";
"3 BSD" -> "4 BSD";
"4 BSD" -> "4.1 BSD";
"4.1 BSD" -> "4.2 BSD";
"4.1 BSD" -> "2.8 BSD";
"4.1 BSD" -> "8th Edition";
"4.2 BSD" -> "4.3 BSD";
"4.2 BSD" -> "Ultrix-32";
"PWB 1.0" -> "PWB 1.2";
"PWB 1.0" -> "USG 1.0";
"PWB 1.2" -> "PWB 2.0";
"USG 1.0" -> "CB Unix 1";
"USG 1.0" -> "USG 2.0";
"CB Unix 1" -> "CB Unix 2";
"CB Unix 2" -> "CB Unix 3";
"CB Unix 3" -> "Unix/TS++";
"CB Unix 3" -> "PDP-11 Sys V";
"USG 2.0" -> "USG 3.0";
"USG 3.0" -> "Unix/TS 3.0";
"PWB 2.0" -> "Unix/TS 3.0";
"Unix/TS 1.0" -> "Unix/TS 3.0";
"Unix/TS 3.0" -> "TS 4.0";
"Unix/TS++" -> "TS 4.0";
"CB Unix 3" -> "TS 4.0";
"TS 4.0" -> "System V.0";
"System V.0" -> "System V.2";
"System V.2" -> "System V.3";
}

0 comments on commit 6bba969

Please sign in to comment.