# Teitz-Bart algorithm applied to Spatial* and Spatial*DataFrame objects

### Description

This function returns the allocations for each demand point - in terms of the index number of
the record in `swdf2`

assigned as the supply point. This version is useful as part of
code inside other functions

### Usage

1 |

### Arguments

`swdf1` |
- first Spatial* or Spatial*DataFrame objects |

`swdf2` |
- second Spatial* or Spatial*DataFrame objects (if omitted, defaults to the same value as |

`force` |
- list of supply points or logical vector with length the same as the number of supply points that are forced to be used - eg existing outlets |

`p` |
- either a guess at the initial |

`metric` |
- the distance matrix (defaults to Euclidean computed via |

`verbose` |
- if TRUE print out each swap in the algorithm (default is FALSE) |

### Value

List of nearest neigbour indices for each element from the *p*-median set

### Examples

1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ```
data(meuse)
coordinates(meuse) <- ~x+y
allocate(meuse,p=5)
require(RColorBrewer)
require(GISTools)
data(georgia)
allocations.list <- allocate(georgia2,p=5)
zones <- gUnaryUnion(georgia2,allocations.list)
plot(zones,col=brewer.pal(5,"Accent"))
plot(georgia2,border=rgb(0,0,0,0.1),add=TRUE)
points(coordinates(georgia2)[allocations.list,],pch=16,cex=2,col=rgb(1,0.5,0.5,0.1))
``` |