Add Edge Dynamically visjs
You can use the vis.js 'update' function to add either nodes or edges dinamycally. You simply pass in an array with the set of either nodes or edges that you are trying to add. You call it like this:
nodes.update(updateNodesArray)
OR
edges.update(updateEdgesArray)
where nodes and edges are the vis.DataSet instances that you originally created for the network.
Full docs can be found at http://visjs.org/docs/data/dataset.html
The intention of this answer is to help my self stop googling it, as I apparently keeps forgetting the solution, and keeps ending up here first...
It is also technically an answer to the question:
function AddEdge(from_id, to_id)
{
network.body.data.edges.add([{from: from_id, to: to_id}])
}
It works as the network data node is a vis dataset, and updating it (also via the add/remove methods) will update the render as well.