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/graph-comb.sml
ViewVC logotype

Annotation of /MLRISC/trunk/graphs/graph-comb.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 411 - (view) (download)
Original Path: sml/branches/SMLNJ/src/MLRISC/graphs/graph-comb.sml

1 : monnier 411 (*
2 :     * This module implements some combinators that joins two graphs
3 :     * into a single view.
4 :     *
5 :     *)
6 :    
7 : monnier 245 structure GraphCombinations : GRAPH_COMBINATIONS =
8 :     struct
9 :    
10 :     structure G = Graph
11 :     structure Union = UnionGraphView
12 :     structure Rename = RenamedGraphView
13 :     structure Rev = ReversedGraphView
14 :    
15 :     (*
16 :     * Disjoint union
17 :     *)
18 :     fun my_union (a,b) = Union.union_view (fn (x,y) => x) (a, b)
19 :     fun sum (A as G.GRAPH a, B as G.GRAPH b) =
20 :     my_union(A, Rename.rename_view (#capacity a ()) B)
21 :     fun union [] = raise G.Graph "union"
22 :     | union [a] = a
23 :     | union [a,b] = my_union(a,b)
24 :     | union (a::b) = my_union(a,union b)
25 :    
26 :     fun sums [] = raise G.Graph "sums"
27 :     | sums [a] = a
28 :     | sums [a,b] = sum(a,b)
29 :     | sums (a::b) = sum(a,sums b)
30 :    
31 :     end
32 :    

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