Changeset 29995 in project for release/4/9MLtoolkit/trunk/smllib/nodegraph.sml
 Timestamp:
 11/05/13 13:44:39 (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

release/4/9MLtoolkit/trunk/smllib/nodegraph.sml
r29994 r29995 4 4 signature NODE_GRAPH = 5 5 sig 6 type symbol = Symbol.symbol 7 type nindex = int 8 type rangemap = (int * int) list 6 type index = int 7 type rangemap = {localStart: int, localEnd: int, globalStart: int} list 9 8 10 val nodeGraph : (s ymbol* SparseMatrix.matrix * rangemap) >11 ( nindex, real, unit) Graph.graph9 val nodeGraph : (string * SparseMatrix.matrix * rangemap) > 10 (index, real, unit) Graph.graph 12 11 13 val junctionMatrix : (( nindex, real, unit) Graph.graph) > SparseMatrix.matrix12 val junctionMatrix : ((index, real, unit) Graph.graph) > SparseMatrix.matrix 14 13 15 14 … … 19 18 struct 20 19 21 type symbol = Symbol.symbol22 20 type index = int 23 21 type rangemap = {localStart: int, localEnd: int, globalStart: int} list … … 25 23 exception Index 26 24 27 fun nodeGraph ( S, rangemap) =25 fun nodeGraph (modelname, S, rangemap) = 28 26 let 29 val mapIndex m i = case List.find (fn (({localStart,localEnd,globalStart} =>30 27 fun mapIndex m i = case List.find (fn {localStart,localEnd,globalStart} => 28 (i >= localStart andalso i < localEnd)) m of 31 29 SOME ({localStart,localEnd,globalStart}) => globalStart + (ilocalStart) 32 30  NONE => raise Index … … 35 33 36 34 val G as Graph.GRAPH g = 37 DirectedGraph.graph( Symbol.namemodelname,(),N) :35 DirectedGraph.graph(modelname,(),N) : 38 36 (index,real,unit) Graph.graph 39 37 … … 45 43 val add_edge = #add_edge g 46 44 47 val _ List.app48 (fn (s) =>49 let50 val sl = SparseMatrix.slice (S,1,i)51 in52 SparseMatrix.sliceAppi53 (fn (t,v) => add_edge (mapIndex rangemap s, mapIndex rangemap t,v))54 sl55 end)56 idxs45 val _ = List.app 46 (fn (s) => 47 let 48 val sl = SparseMatrix.slice (S,1,s) 49 in 50 SparseMatrix.sliceAppi 51 (fn (t,v) => add_edge (mapIndex rangemap s, mapIndex rangemap t,v)) 52 sl 53 end) 54 idxs 57 55 58 56 in 59 57 G 60 58 end 59 61 60 62 61 fun junctionMatrix (Graph.GRAPH g) =
Note: See TracChangeset
for help on using the changeset viewer.