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

Annotation of /MLRISC/trunk/graphs/singleton.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 245 - (view) (download)
Original Path: sml/branches/SMLNJ/src/MLRISC/graphs/singleton.sml

1 : monnier 245
2 :     (*
3 :     * Make a singleton graph
4 :     *)
5 :    
6 :     signature SINGLETON_GRAPH_VIEW =
7 :     sig
8 :    
9 :     val singleton_view : ('n,'e,'g) Graph.graph ->
10 :     Graph.node_id -> ('n,'e,'g) Graph.graph
11 :    
12 :     end
13 :    
14 :     structure SingletonGraphView : SINGLETON_GRAPH_VIEW =
15 :     struct
16 :    
17 :     structure G = Graph
18 :    
19 :     fun singleton_view (G.GRAPH G) n =
20 :     let fun unimplemented _ = raise G.Readonly
21 :     fun none _ = []
22 :     fun entries () = case #in_edges G n of [] => [] | _ => [n]
23 :     fun exits () = case #out_edges G n of [] => [] | _ => [n]
24 :     in
25 :     G.GRAPH
26 :     { name = #name G,
27 :     graph_info = #graph_info G,
28 :     new_id = #new_id G,
29 :     add_node = unimplemented,
30 :     add_edge = unimplemented,
31 :     remove_node = unimplemented,
32 :     set_in_edges = unimplemented,
33 :     set_out_edges = unimplemented,
34 :     set_entries = unimplemented,
35 :     set_exits = unimplemented,
36 :     garbage_collect = unimplemented,
37 :     nodes = fn _ => [(n,#node_info G n)],
38 :     edges = none,
39 :     order = fn _ => 1,
40 :     size = fn _ => 0,
41 :     capacity = #capacity G,
42 :     out_edges = none,
43 :     in_edges = none,
44 :     succ = none,
45 :     pred = none,
46 :     has_edge = fn _ => false,
47 :     has_node = fn i => i = n,
48 :     node_info = #node_info G,
49 :     entries = entries,
50 :     exits = exits,
51 :     entry_edges = fn i => if i = n then #in_edges G i else [],
52 :     exit_edges = fn i => if i = n then #out_edges G i else [],
53 :     forall_nodes = fn f => f(n,#node_info G n),
54 :     forall_edges = fn f => ()
55 :     }
56 :     end
57 :     end
58 :    
59 :     (*
60 :     * $Log$
61 :     *)

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