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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 545 - (view) (download)

1 : monnier 409 (*
2 :     * This combinator allows you to get a cached copy of a graph.
3 :     *
4 :     * -- Allen
5 :     *)
6 :    
7 :     signature GRAPH_SNAPSHOT =
8 :     sig
9 :     val snapshot : ('n,'e,'g) Graph.graph ->
10 :     { picture : ('n,'e,'g) Graph.graph,
11 :     button : unit -> unit
12 :     }
13 :     end
14 :    
15 :     (*
16 :     * This is a naive implementation.
17 :     *)
18 : george 545 functor GraphSnapShot(GI : GRAPH_IMPLEMENTATION) : GRAPH_SNAPSHOT =
19 : monnier 409 struct
20 :    
21 :     structure G = Graph
22 :     fun snapshot (G.GRAPH G) =
23 :     let val pict as G.GRAPH G' = GI.graph(#name G,#graph_info G,#capacity G ())
24 :     fun clear() = #forall_nodes G' (fn (n,_) => #remove_node G' n)
25 :     fun copy() =
26 :     (#forall_nodes G (#add_node G');
27 :     #forall_edges G (#add_edge G');
28 :     #set_entries G' (#entries G ());
29 :     #set_exits G' (#exits G ())
30 :     )
31 :     fun button() = (clear(); copy())
32 :     in copy();
33 :     { picture = pict, button = button }
34 :     end
35 :     end
36 :    

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