I am using Erlang's digraph module for storing Directed Acyclic Graphs (DAGs). So for argument's sake here is a super simple graph (using Elixir):
gr = :digraph.new()
:digraph.add_vertex(gr, "A")
:digraph.add_vertex(gr, "B")
:digraph.add_vertex(gr, "C")
:digraph.add_edge(gr, "A", "B")
:digraph.add_edge(gr, "A", "C")
which looks like this:
We can see it's all worked:
iex(7)> :digraph.vertices(gr)
["A", "C", "B"]
iex(8)> :digraph.edges(gr)
[[:"$e" | 0], [:"$e" | 1]]
iex(9)> :digraph.out_neighbours(gr, "A")
["C", "B"]
iex(10)> :digraph.out_neighbours(gr, "B")
[]
iex(11)> :digraph.out_neighbours(gr, "C")
[]
iex(12)> :digraph_utils.is_acyclic(gr)
true
Now I'm going to be adding and removing more vertices and edges, but I would like to transmit these graphs to applications outside of the Elixir/Erlang ecosystem such as Cytoscape.js. Is there a standardized way to serialize digraphs into some industry standard readable format (json or xml for example), such as JGF, Netlix's Falcor JSON Graph format, or other?
I could write my own serializer but I'd prefer something pre-existing. I can't find anything that does this in digraph or digraph_utils.
Searching there are various solutions for exporting digraph data to various popular formats, but nothing canonical Two of the most popular of these formats are DOT and GraphML.
Some Elixir and Erlang libraries for exporting digraphs to various formats:
Some Elixir and Erlang examples of updating the front-end in soft realtime using js libs such as vis.js and web sockets:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With