public static <VertexType extends BaseVertex
            , EdgeType extends BaseEdge<VertexType>>
    BaseGraph<VertexType, EdgeType> sum(BaseGraph<VertexType, EdgeType> g1, BaseGraph<VertexType, EdgeType> g2) {
        BaseGraph<VertexType, EdgeType> g = g1.createEmptyGraph();
        HashMap<VertexType, VertexType> temp = new HashMap<VertexType, VertexType>();
        HashSet<EdgeType> E = new HashSet<EdgeType>();

        for (VertexType v : g1) {
            VertexType vt = (VertexType) v.getCopy();
            temp.put(v, vt);
            g.insertVertex(vt);
        }
        for (VertexType v : g2) {
            VertexType vt = (VertexType) v.getCopy();
            temp.put(v, vt);
            g.insertVertex(vt);
        }

        Iterator<EdgeType> iet = g1.lightEdgeIterator();
        while (iet.hasNext()) {
            EdgeType e = iet.next();
            E.add((EdgeType) e.getCopy(temp.get(e.source), temp.get(e.target)));
            //E.add(iet.next());
        }

        iet = g2.lightEdgeIterator();
        while (iet.hasNext()) {
            EdgeType e = iet.next();
            E.add((EdgeType) e.getCopy(temp.get(e.source), temp.get(e.target)));
        }

        EdgeType ee = g1.getEdges().iterator().next();
        for (VertexType v1 : g1) {
            for (VertexType v2 : g2) {
                E.add((EdgeType) ee.getCopy(temp.get(v1),
                        temp.get(temp.get(v2))));
            }
        }

        for (EdgeType e : E) {
            try {
                g.insertEdge(e);
            } catch (InvalidVertexException e1) {
                e1.printStackTrace();
            }
        }
        return g;
    }