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

SCM Repository

[smlnj] Diff of /MLRISC/trunk/graphs/ugraph.sml
ViewVC logotype

Diff of /MLRISC/trunk/graphs/ugraph.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 411, Fri Sep 3 00:25:03 1999 UTC revision 429, Wed Sep 8 09:47:00 1999 UTC
# Line 15  Line 15 
15  struct  struct
16    
17     structure G = Graph     structure G = Graph
18     structure Sort = Sorting     structure Sort = ListMergeSort
19    
20     fun undirected_view (G.GRAPH G) =     fun undirected_view (G.GRAPH G) =
21     let fun adjacent_edges i =     let fun adjacent_edges i =
22         let val in_edges  = map (fn (i,j,e) => (j,i,e)) (#in_edges G i)         let val in_edges  = map (fn (i,j,e) => (j,i,e)) (#in_edges G i)
23             val out_edges = #out_edges G i             val out_edges = #out_edges G i
24         in         in
25             Sort.sort_uniq (fn ((i,j,_),(i',j',_)) =>             Sort.uniqueSort (fn ((i,j,_),(i',j',_)) =>
26                                 i < i' orelse i = i' andalso j < j')                                if i < i' then LESS
27                            (fn ((i,j,_),(i',j',_)) => i = i' andalso j = j')                                else if i = i' then
28                                       if j < j' then LESS
29                                       else if j = j' then EQUAL
30                                       else GREATER
31                                  else GREATER)
32                            (in_edges @ out_edges)                            (in_edges @ out_edges)
33         end         end
34         fun adjacent_nodes i =         fun adjacent_nodes i =
35         let val succ = #succ G i         let val succ = #succ G i
36             val pred = #pred G i             val pred = #pred G i
37         in         in
38             Sort.sort_uniq op< op= (succ @ pred)             Sort.uniqueSort Int.compare (succ @ pred)
39         end         end
40    
41         fun has_edge (i,j) = #has_edge G (i,j) orelse #has_edge G (j,i)         fun has_edge (i,j) = #has_edge G (i,j) orelse #has_edge G (j,i)

Legend:
Removed from v.411  
changed lines
  Added in v.429

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