Skip to content

Commit

Permalink
graphviz: tweak data structure slightly
Browse files Browse the repository at this point in the history
A node's edges contain an associative array of target nodes rather than
a linear array.

This way we automatically dedup edges when we load multiple graphs.
  • Loading branch information
akkartik committed Mar 19, 2022
1 parent 03a3883 commit a05f713
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions graphviz.tlv
Original file line number Diff line number Diff line change
Expand Up @@ -738,10 +738,9 @@
> -- edge_stmt
> local tok3 = tokens:read()
> if graph[tok1] == nil then
> graph[tok1] = {tok3}
> else
> append(graph[tok1], {tok3})
> graph[tok1] = {}
> end
> graph[tok1][tok3] = true
> elseif tok2 == '--' then
> error('unexpected token "--" in digraph; edges should be directed using "->"')
> elseif tok2 == '=' then
Expand Down Expand Up @@ -808,7 +807,7 @@
>function sources(Graph)
> local is_target = {}
> for source, targets in pairs(Graph) do
> for _, target in ipairs(targets) do
> for target, _ in pairs(targets) do
> is_target[target] = true
> end
> end
Expand Down

0 comments on commit a05f713

Please sign in to comment.