# Path: route_model/config/network_config.py
# class NetworkConfig(UserDict):
# 	"""store network configuration data"""
# 	
# 	def __init__(self, changes={}):
# 		UserDict.__init__(self)
# 		self['data_dir']=r"X:\Projects\BikeModel\data\route_model\input\network\test"
# 		self['link_file']=os.path.join(self['data_dir'],'links.csv')
# 		self['node_file']=os.path.join(self['data_dir'],'nodes.csv')
# 		self['dist_var']='DISTANCE'
# 		self['dist_scl']=1 #rescales with node distance x dist_scl= link distance
# 		self['max_centroid']=None
# 
# 		for key in changes:
# 			self[key]=changes[key]


from networkx.classes.digraph import DiGraph
from math import sqrt, acos, pi
from numpy import *
from route_model.config.network_config import NetworkConfig
import os, csv
import unittest
			
			infile.close()
			
			if 'node_file' in config:
				self.create_node_xy_from_csv(config)
				
		self.orig_network=None
	
	def create_node_xy_from_csv(self,config):
		"""fill out the geographical node locations from the csv file"""
		
		infile=open(config['node_file'])
		reader=csv.reader(infile)

		self.node_xy={}

		for row in reader:
			if row[0]=='N': continue
			else: self.node_xy[int(row[0])]=(float(row[1]),float(row[2]))
				
		infile.close()
	
	def select_edges_where(self,varname,operator,value_or_iterable,data=True):
		"""allowed operators: '<', '==', '>', '<=', '>=', '!=', 'in', 'not in'
		list of values allowed only if operator is 'in' or 'not in'"""
		
		ebunch=[]
		
		try:
			iter(value_or_iterable)

# Path: route_model/config/network_config.py
# class NetworkConfig(UserDict):
# 	"""store network configuration data"""
# 	
# 	def __init__(self, changes={}):
# 		UserDict.__init__(self)
# 		self['data_dir']=r"X:\Projects\BikeModel\data\route_model\input\network\test"
# 		self['link_file']=os.path.join(self['data_dir'],'links.csv')
# 		self['node_file']=os.path.join(self['data_dir'],'nodes.csv')
# 		self['dist_var']='DISTANCE'
# 		self['dist_scl']=1 #rescales with node distance x dist_scl= link distance
# 		self['max_centroid']=None
# 
# 		for key in changes:
# 			self[key]=changes[key]


# Path: route_model/transport_network.py
from networkx.classes.digraph import DiGraph
from math import sqrt, acos, pi
from numpy import *
from route_model.config.network_config import NetworkConfig
import os, csv
import unittest

			
			infile.close()
			
			if 'node_file' in config:
				self.create_node_xy_from_csv(config)
				
		self.orig_network=None
	
	def create_node_xy_from_csv(self,config):
		"""fill out the geographical node locations from the csv file"""
		
		infile=open(config['node_file'])
		reader=csv.reader(infile)

		self.node_xy={}

		for row in reader:
			if row[0]=='N': continue
			else: self.node_xy[int(row[0])]=(float(row[1]),float(row[2]))
				
		infile.close()
	
	def select_edges_where(self,varname,operator,value_or_iterable,data=True):
		"""allowed operators: '<', '==', '>', '<=', '>=', '!=', 'in', 'not in'
		list of values allowed only if operator is 'in' or 'not in'"""
		
		ebunch=[]
		
		try:
			iter(value_or_iterable)

			if operator not in ['in', 'not in']: