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

# SCM Repository

[smlnj] View of /sml/trunk/src/MLRISC/graphs/ugraph.sml
 [smlnj] / sml / trunk / src / MLRISC / graphs / ugraph.sml

# View of /sml/trunk/src/MLRISC/graphs/ugraph.sml

Fri Sep 3 00:25:03 1999 UTC (20 years, 1 month ago) by monnier
File size: 2235 byte(s)
```This commit was generated by cvs2svn to compensate for changes in r411,
which included commits to RCS files with non-trunk default branches.
```
```(*
*  Undirected graph view.  This makes a graph look undirected.
*
*  -- Allen
*)

signature UNDIRECTED_GRAPH_VIEW =
sig

val undirected_view : ('n,'e,'g) Graph.graph -> ('n,'e,'g) Graph.graph

end

structure UndirectedGraphView : UNDIRECTED_GRAPH_VIEW =
struct

structure G = Graph
structure Sort = Sorting

fun undirected_view (G.GRAPH G) =
let val in_edges  = map (fn (i,j,e) => (j,i,e)) (#in_edges G i)
val out_edges = #out_edges G i
in
Sort.sort_uniq (fn ((i,j,_),(i',j',_)) =>
i < i' orelse i = i' andalso j < j')
(fn ((i,j,_),(i',j',_)) => i = i' andalso j = j')
(in_edges @ out_edges)
end
let val succ = #succ G i
val pred = #pred G i
in
Sort.sort_uniq op< op= (succ @ pred)
end

fun has_edge (i,j) = #has_edge G (i,j) orelse #has_edge G (j,i)

in
G.GRAPH
{ name            = #name G,
graph_info      = #graph_info G,
new_id          = #new_id G,
remove_node     = #remove_node G,
set_in_edges    = #set_in_edges G,
set_out_edges   = #set_out_edges G,
set_entries     = #set_exits G,
set_exits       = #set_entries G,
garbage_collect = #garbage_collect G,
nodes           = #nodes G,
edges           = #edges G,
order           = #order G,
size            = #size G,
capacity        = #capacity G,
has_edge        = has_edge,
has_node        = #has_node G,
node_info       = #node_info G,
entries         = #exits G,
exits           = #entries G,
entry_edges     = #entry_edges G,
exit_edges      = #exit_edges G,
forall_nodes    = #forall_nodes G,
forall_edges    = #forall_edges G
}
end
end

```