Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/src/MLRISC/graphs/snap-shot.sml
ViewVC logotype

View of /sml/trunk/src/MLRISC/graphs/snap-shot.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 651 - (download) (annotate)
Thu Jun 1 18:34:03 2000 UTC (19 years, 3 months ago) by monnier
File size: 884 byte(s)
bring revisions from the vendor branch to the trunk
(*
 * This combinator allows you to get a cached copy of a graph.
 *
 * -- Allen
 *)

signature GRAPH_SNAPSHOT =
sig
   val snapshot : ('n,'e,'g) Graph.graph -> 
        { picture : ('n,'e,'g) Graph.graph,
          button : unit -> unit
        }
end

(*
 * This is a naive implementation.
 *)
functor GraphSnapShot(GI : GRAPH_IMPLEMENTATION) : GRAPH_SNAPSHOT =
struct

   structure G = Graph
   fun snapshot (G.GRAPH G) =
   let val pict as G.GRAPH G' = GI.graph(#name G,#graph_info G,#capacity G ())
       fun clear() = #forall_nodes G' (fn (n,_) => #remove_node G' n)
       fun copy() =
          (#forall_nodes G (#add_node G');
           #forall_edges G (#add_edge G');
           #set_entries G' (#entries G ());
           #set_exits G' (#exits G ())
          )
       fun button() = (clear(); copy())
   in  copy();
       { picture = pict, button = button }
   end
end


root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0