// Learn more about F# at http://fsharp.net// See the 'F# Tutorial' project for more help.module File1open System.Windows.Formsopen System.Collections.Generictype Loc = |A|B|C|Dlet path_key a b = if aList.map (fun (a,b,c)->((path_key a b)),c) |>Map.ofListpath_Dis_map |> Map.toList |>printfn "%A" //let dict = new Dictionary()let path_Dis_map2 = new Dictionary< Loc*Loc , int>()//Map.tryFind let path_map_query ls map1= match ls with |head::val1::tail-> if ( Map.containsKey (A,head) map1) then map1.[(A,head)] else System.Int32.MaxValue |_->System.Int32.MaxValuelet rec path_cdis ls= match ls with |head::a::tail-> let dis1 = path_Dis_map.[path_key head a] dis1 + path_cdis(a::tail) |_->0printfn "dis = %d %d" (path_cdis [D;C;B;A]) (path_map_query [D;C;B;A] path_Dis_map)let fileterme crr value= match value with | (a,b,c) when a=crr -> Some(b) | (a,b,c) when b=crr ->Some(a) | _ ->Nonelet findway (ls:Loc list) = List.choose (fileterme ls.Head) pathData |> List.filter (fun x-> not ( List.exists (fun i->i=x) ls))let start1 =[[A]]let rec work2 (start,pathmaps)= let once = List.collect (fun (ls)-> let firstList = ls//List.head start let ways = findway firstList match ways with |[] -> [] |_-> let ends = List.map (fun x ->x::ls) ways ends ) start let map1 = pathmaps let Mapme = once|> List.fold (fun (acc:Map<(Loc*Loc),int>) (ls:Loc list)-> let k=A,ls.Head let v= path_cdis ls match (Map.tryFind k acc) with |Some n-> if v< n then Map.add k v acc else acc |_->Map.add k v acc ) map1 // //Mapme|>printf "Map me %A" List.filter (fun x-> match x with |D::tail -> printfn "Find the way %A = %d" x (path_cdis x) false |_->true ) once |>printfn "%A" //裁剪路径 let once3 = List.filter (fun (ls:Loc list)-> let k=A,ls.Head let v= path_cdis ls match (Map.tryFind k Mapme) with |Some n-> if v <= n then true else false |_->true ) once |> List.filter (fun (x:Loc list)-> not (D = x.Head)) //once3 |> printfn ">>>>Left is %A" once3,Mapmelet rec work1 (start,map) = match start with |[] ->() |_-> let data = work2 (start,map) work1 datawork1 (start1,path_Dis_map) |> printfn ">>>%A"[ ]let main argv = printfn "%A" argv 0 // return an integer exit code