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 412 - (view) (download)
Original Path: sml/trunk/src/MLRISC/graphs/singleton.sml

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

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