(define (edge-item-set-crds ei)
	(let* ((es (car (slot-ref ei 'seg-list)))
	       (e  (edge ei))
	       (crds (slot-ref es 'coords))
	       (wcrds (view-to-world (car crds) (cadr crds) (graph-view ei))))
	    (set-double-attribute! 'x (car wcrds) e)
	    (set-double-attribute! 'y (cadr wcrds) e)
	)
)

(define (mysave gv fname)
	(map edge-item-set-crds (edges gv))
	(save-graph (graph gv) fname))

(define (place-edge ei)
	(let* ((e  (edge ei))
	       (es (car (slot-ref ei 'seg-list)))
	       (xcrd (find-double-attribute 'x e))
	       (ycrd (find-double-attribute 'y e))
	       (vcrds (world-to-view xcrd ycrd (graph-view ei))))
	   (slot-set! es 'coords vcrds)))

(define (place-edges gv)
	(map place-edge (edges gv)))

(define (update-vertex-label new-v old-v)
	(slot-set! (vertex-item new-v) 'vertex-label 
		   (find-string-attribute 'label old-v)))

(define (update-edge-label new-e old-e)
	(slot-set! (edge-item new-e) 'edge-label 
		   (find-string-attribute 'label old-e)))

(define (update-labels gv old-g)
	(let* ((new-g (graph gv))
	       (old-edges (mset-edge->list (edges old-g)))
	       (new-edges (mset-edge->list (edges new-g)))
	       (new-vertices (set-vertex->list (vertices new-g)))
	       (old-vertices (set-vertex->list (vertices old-g))))
	   (map update-edge-label new-edges old-edges)
	   (map update-vertex-label new-vertices old-vertices)))

(define (myload fname)
	(let*((g (load-graph fname))
	      (gv (show-graph g 'custom)))
		(place-edges gv)
		(update-labels gv g)))
