Guest User

Untitled

a guest
Jun 13th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. to find-clusters
  2. loop [
  3. ;; pick a random patch that isn't in a cluster yet
  4. let seed one-of patches with [cluster = nobody
  5. and pcolor = 8
  6. ]
  7. ;; if we can't find one, then we're done!
  8. if seed = nobody
  9. [
  10. stop ]
  11. ;; otherwise, make the patch the "leader" of a new cluster
  12. ;; by assigning itself to its own cluster, then call
  13. ;; grow-cluster to find the rest of the cluster
  14. ask seed
  15. [ set cluster self
  16. grow-cluster ]]
  17. display
  18. end
  19.  
  20. to grow-cluster ;; patch procedure
  21. ask neighbors4 with [(cluster = nobody
  22. and pcolor = 8
  23. ) and
  24. (pcolor = [pcolor] of myself)]
  25. [ set cluster [cluster] of myself
  26. grow-cluster ]
  27. end
  28.  
  29. to calc-frequency
  30. let freq map [[i] -> count patches with [cluster = i]] remove-
  31. duplicates [cluster] of patches
  32.  
  33. set-current-plot "Frequency distribution of urban patch size"
  34. histogram freq
  35. end
Add Comment
Please, Sign In to add comment