Advertisement
Guest User

Untitled

a guest
Mar 25th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.74 KB | None | 0 0
  1. (*23*)
  2. let fromVertice (g : IGraph) v =
  3.     let byEdgeFromSet r =
  4.         List.concat (List.map g.OutByEdge r)
  5.     let exclude exclusionPredicate list =
  6.         List.filter (fun u -> not (exclusionPredicate u)) list
  7.     let excludeAll exclusionList list =
  8.         exclude (fun u -> List.exists (isVertice u) exclusionList) list
  9.     let rec fromVerticeSet r =
  10.         let p = excludeAll r (byEdgeFromSet r)
  11.         if p = [] then r else fromVerticeSet (p @ r)
  12.     fromVerticeSet [v]
  13.  
  14. (*24*)
  15. let toVertice (g : IGraph) v =
  16.     let destReachableFrom x =
  17.         List.exists (isVertice v) (fromVertice g x)
  18.     let accumulateVertice acc x =
  19.         if destReachableFrom x then x :: acc else acc
  20.     List.fold accumulateVertice [] [0 .. g.Size-1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement