@classmethod
def from_directed_graph(cls, directed_graph):
    """ Generate an undirected graph by turning a directed graph's edges
            into undirected edges and removing duplicate edges """
    g = cls()
    for v in directed_graph.vertices:
        g.add_vertex(v.val)
    for e in directed_graph.edges:
        v_vals = e.v_from.val, e.v_to.val
        if not g.has_edge(v_vals):
            g.add_edge(v_vals)
    return g
