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 /MLRISC/trunk/graphs/snap-shot.sml
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2126 - (download) (annotate)
Thu Nov 2 16:11:29 2006 UTC (12 years, 9 months ago) by blume
File size: 884 byte(s)
moved MLRISC to toplevel
(*
 * 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