forked from AlbertoCassese/BNSP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
neighbor.R
54 lines (54 loc) · 3.9 KB
/
neighbor.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
neighbor=function(){
num.state = 48
NEIGHBOR = matrix(0,num.state,num.state)
dimnames(NEIGHBOR) = list(state.name[c(-2,-11)],state.name[c(-2,-11)])
NEIGHBOR["Alabama",c("Mississippi","Tennessee","Georgia","Florida")]=1
NEIGHBOR["Arizona",c("California","Nevada","Utah","Colorado","New Mexico")]=1
NEIGHBOR["Arkansas",c("Oklahoma","Missouri","Tennessee","Mississippi","Louisiana","Texas")]=1
NEIGHBOR["California",c("Oregon","Nevada","Arizona")]=1
NEIGHBOR["Colorado",c("Wyoming","Utah","New Mexico","Oklahoma","Kansas","Nebraska","Arizona")]=1
NEIGHBOR["Connecticut",c("New York","Massachusetts","Rhode Island")]=1
NEIGHBOR["Delaware",c("Maryland","Pennsylvania","New Jersey")]=1
NEIGHBOR["Florida",c("Alabama","Georgia")]=1
NEIGHBOR["Georgia",c("Florida","Alabama","Tennessee","North Carolina","South Carolina")]=1
NEIGHBOR["Idaho",c("Washington","Montana","Wyoming","Utah","Nevada","Oregon")]=1
NEIGHBOR["Illinois",c("Missouri","Wisconsin","Iowa","Indiana","Kentucky","Michigan")]=1
NEIGHBOR["Indiana",c("Illinois","Kentucky","Ohio","Michigan")]=1
NEIGHBOR["Iowa",c("Nebraska","South Dakota","Minnesota","Wisconsin","Illinois","Missouri")]=1
NEIGHBOR["Kansas",c("Oklahoma","Colorado","Nebraska","Missouri")]=1
NEIGHBOR["Kentucky",c("Tennessee","Missouri","Illinois","Indiana","Ohio","West Virginia","Virginia")]=1
NEIGHBOR["Louisiana",c("Texas","Arkansas","Mississippi")]=1
NEIGHBOR["Maine",c("New Hampshire")]=1
NEIGHBOR["Maryland",c("Virginia","West Virginia","Pennsylvania","Delaware")]=1
NEIGHBOR["Massachusetts",c("Rhode Island","Connecticut","New York","Vermont","New Hampshire")]=1
NEIGHBOR["Michigan",c("Indiana","Ohio","Illinois","Wisconsin")]=1
NEIGHBOR["Minnesota",c("North Dakota","South Dakota","Iowa","Wisconsin")]=1
NEIGHBOR["Mississippi",c("Louisiana","Arkansas","Tennessee","Alabama")]=1
NEIGHBOR["Missouri",c("Arkansas","Oklahoma","Kansas","Nebraska","Iowa","Illinois","Kentucky","Tennessee")]=1
NEIGHBOR["Montana",c("Idaho","Wyoming","South Dakota","North Dakota")]=1
NEIGHBOR["Nebraska",c("Kansas","Colorado","Wyoming","South Dakota","Iowa","Missouri")]=1
NEIGHBOR["Nevada",c("California","Oregon","Idaho","Utah","Arizona")]=1
NEIGHBOR["New Hampshire",c("Massachusetts","Vermont","Maine")]=1
NEIGHBOR["New Jersey",c("Delaware","Pennsylvania","New York")]=1
NEIGHBOR["New Mexico",c("Arizona","Colorado","Oklahoma","Texas","Utah")]=1
NEIGHBOR["New York",c("Pennsylvania","New Jersey","Connecticut","Vermont","Massachusetts")]=1
NEIGHBOR["North Carolina",c("South Carolina","Georgia","Tennessee","Virginia")]=1
NEIGHBOR["North Dakota",c("Montana","South Dakota","Minnesota")]=1
NEIGHBOR["Ohio",c("Michigan","Indiana","Kentucky","West Virginia","Pennsylvania")]=1
NEIGHBOR["Oklahoma",c("Texas","New Mexico","Colorado","Kansas","Missouri","Arkansas")]=1
NEIGHBOR["Oregon",c("Washington","Idaho","Nevada","California")]=1
NEIGHBOR["Pennsylvania",c("West Virginia","Ohio","New York","New Jersey","Delaware","Maryland")]=1
NEIGHBOR["Rhode Island",c("Connecticut","Massachusetts")]=1
NEIGHBOR["South Carolina",c("Georgia","North Carolina")]=1
NEIGHBOR["South Dakota",c("Nebraska","Wyoming","Montana","North Dakota","Minnesota","Iowa")]=1
NEIGHBOR["Tennessee",c("Georgia","Alabama","Mississippi","Arkansas","Missouri","Kentucky","Virginia","North Carolina")]=1
NEIGHBOR["Texas",c("New Mexico","Oklahoma","Arkansas","Louisiana")]=1
NEIGHBOR["Utah",c("Arizona","Nevada","Idaho","Wyoming","Colorado","New Mexico")]=1
NEIGHBOR["Vermont",c("New York","Massachusetts","New Hampshire")]=1
NEIGHBOR["Virginia",c("North Carolina","Tennessee","Kentucky","West Virginia","Maryland")]=1
NEIGHBOR["Washington",c("Oregon","Idaho")]=1
NEIGHBOR["West Virginia",c("Virginia","Kentucky","Ohio","Pennsylvania","Maryland")]=1
NEIGHBOR["Wisconsin",c("Minnesota","Iowa","Illinois","Michigan")]=1
NEIGHBOR["Wyoming",c("Montana","Idaho","Utah","Colorado","Nebraska","South Dakota")]=1
return(NEIGHBOR)
}