graphCost = graph => {
    let total = 0;
    graph.vertices.forEach(vertex => {
      total += graph
        .neighbors(vertex)
        .reduce((accum, neighbor) => accum + graph.edge(vertex, neighbor), 0);
    });
    return graph.directed ? total : total / 2;
  }
Sum up graph edge weights.

@param {Graph} graph
@return {number}