What is the best way to use an external js library server-side?

I’m starting to learn Phoenix / Elixir and I would like to use a graph-theory library on the server. I know Cytoscape.js which I’ve used in node projects. I also know Cytoscape exists in java
Is it possible (and does it make sense) to use such a library?
If not, are there alternatives?
Thanks

1 Like

Do you want to call js functions from elixir? Maybe https://github.com/devinus/execjs fits?

1 Like

Thanks Stefan. I’d like to call js functions from Elixir, yes.

Cytoscape can receive a json object that contains the nodes and edges information of a graph. Then, you can traverse the graph, browse, sort, etc. using very powerful algorithms.

I’m looking for the best technical solution to either use Cytoscape.js from Elixir on the server, or if there is another graph-theory library for elixir (didn’t find anything so far)

1 Like

Erlang’s standard library has a graph theory module called digraph. I haven’t gotten the chance to use it yet, but I was excited to learn of its existence.

1 Like

Calling js from elixir is very simple using that lib. You already have node on the server with phoenix, just put the dep in mix.exs, mix deps.update --all and try a call as documented on github.

1 Like

Thanks to both of you. I’ll investigate both options!

1 Like