Easiest way to export graph
eadz opened this issue · 2 comments
Hi,
What is the easiest way to export a graph database of the node ids?
for example
node1 -> node2
node2 -> node3
etc?
Thanks
@eadz
I dont know if I understand you correctly and you need to get ID of several elements:
You can get ID of any icon or line by copy
it and paste
in notepad. First number is its ID.
For example, here:
DRAKON 1.23 items {{15 action {} {} {} 1 170 340 50 20 0 0}}
15
is ID of icon.
Create a code generator that will output the graph instead of generating code.
The handle to the in-memory database with the graph will be passed to your "generate" procedure as the second parameter.
Please note, that there are two graphs: the visual rectangular graph and the "algorithmic" graph.
See the schema the SQL script in the scripts/graph.tcl.
You are probably interested in the algorithmic graph. The nodes are stored in the "vertices" table. The edges are stored in the "links" table.
Here is an example generator that would print out the graph:
# put this tcl file in the "generators" folder
gen::add_generator "Graph to standard output" gen_text::generate
namespace eval gen_text {
proc generate { db gdb filename } {
$gdb eval {
select diagram_id, name
from diagrams
order by name
} {
puts "==== diagram '$name' ===="
puts "vertices:"
$gdb eval {
select vertex_id, item_id, type, text, text2
from vertices
where diagram_id = :diagram_id
} {
puts "$vertex_id $item_id $type $text $text2"
puts " links:"
$gdb eval {
select src, ordinal, dst, direction, constant
from links
where src = :vertex_id
order by ordinal
} {
puts " $src, $ordinal, $dst, $direction, $constant"
}
}
puts ""
}
}
}