Skip to content

json exporting #82

Description

@jarlebring

For presenting and visualization of our work, it would be cool to generate 3d-force-graphs of the computation graphs using

https://github.com/vasturiano/3d-force-graph/

We need

a) functionality to export the computation graph to a json format. This could either be a separate function 1) export_json or 2) a part of gen_code with LangJSON. At the moment I would say option 1) since it would not need the memory management functionality.

b) some javascript that reads the json and encodes operations / coefficients etc graphically in the 3d-force-graph format wanted in that library

Point a) should be rather straightforward if we add dependence JSON.jl following this:

using JSON

nodes=Vector{Any}();
links=Vector{Any}();
for n in keys(g.nodes)
    push!(nodes,Dict("id" => sting(n), "operation" => string(g.operations[n]))); 
    for (i,n2) = enumerate(g.parents[n])
        d=Dict{String,Any}("source" => string(n),
                           "target" => string(n2),
                          "weight" => string(2);
      push!(links,d)
    end
end
json=Dict("nodes" => nodes, "links" => links);
open("comp_tree.json","w") do f
    JSON.print(f, json)
end

Javascript examples:
https://people.kth.se/~eliasj/watkins-graph-small.html
https://people.kth.se/~eliasj/large-graph.html

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions