Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- to find-clusters
- loop [
- ;; pick a random patch that isn't in a cluster yet
- let seed one-of patches with [cluster = nobody
- and pcolor = 8
- ]
- ;; if we can't find one, then we're done!
- if seed = nobody
- [
- stop ]
- ;; otherwise, make the patch the "leader" of a new cluster
- ;; by assigning itself to its own cluster, then call
- ;; grow-cluster to find the rest of the cluster
- ask seed
- [ set cluster self
- grow-cluster ]]
- display
- end
- to grow-cluster ;; patch procedure
- ask neighbors4 with [(cluster = nobody
- and pcolor = 8
- ) and
- (pcolor = [pcolor] of myself)]
- [ set cluster [cluster] of myself
- grow-cluster ]
- end
- to calc-frequency
- let freq map [[i] -> count patches with [cluster = i]] remove-
- duplicates [cluster] of patches
- set-current-plot "Frequency distribution of urban patch size"
- histogram freq
- end
Add Comment
Please, Sign In to add comment