This is a group of Python programs written to find networks in a data set of cities.
The function storeConnections()
from storeConnections.py
will take a map of cities to a list of their neighbors (within some predetermined radius), and generate an array containing all unique networks of cities in the data set.
from storeConnections import storeConnections
neighborMap = {}
# populate the map with {String, [String]} pairs of cities to their neighbors
# ex: neighborMap["San Francisco"] = ["Palo Alto", "Sunnyvale", "Redwood Shores", "Oakland"]
networkList = storeConnections(neighborMap)
# now use the list of networks for your purposes
Run bash test.sh
to display the results of both test programs.
The compare()
method in storeConnections.py
is used to check if two unordered arrays contain the same contents. It comes from this StackOverflow discussion.
-Ian Marx, June 2017