function createEdge(graph, from, to, type, attr) {
  var edge = {
    from: from,
    to: to,
    type: type,
  };

  if (graph.edge) {
    edge.attr = merge({}, graph.edge); // clone default attributes
  }
  edge.attr = merge(edge.attr || {}, attr); // merge attributes

  // Move arrows attribute from attr to edge temporally created in
  // parseAttributeList().
  if (attr != null) {
    if (attr.hasOwnProperty("arrows") && attr["arrows"] != null) {
      edge["arrows"] = { to: { enabled: true, type: attr.arrows.type } };
      attr["arrows"] = null;
    }
  }
  return edge;
}
Create an edge to a graph object
@param {object} graph
@param {string | number | object} from
@param {string | number | object} to
@param {string} type
@param {object | null} attr
@returns {object} edge