class Controller(object):
	def __init__(self):
		self.sched = SeqScheduler.SeqScheduler("sequential")
		self.clusteringsched = None
		self.graphs = []

	def addClusteringSched(self, m, p):
		self.clusteringsched = SchedulerBAClustering(m, p)
		self.sched.add_rule(self.clusteringsched)
	def addWriteRule(self, prefix):
		wr = WriteRule(None, prefix)
		self.sched.add_rule(wr)
	def addBARule(self, m, l):
		gba = GrowthRuleBA.GrowthRuleBA(None, m, l)
		self.clusteringsched.add_rule(gba, "BA")
	def addRandAttackRule(self, per):
		ra = AttackRuleRandom(None, per)
		self.sched.add_rule(ra)
	def addHighDegreeAttackRule(self, per):
		rh = AttackRuleHighDegree(None, per)
		self.sched.add_rule(rh)
	def replaceBARule(self, m, l):
		g = self.graphs[-1]
		gba = GrowthRuleBA.GrowthRuleBA(g, m, l)
		self.clusteringsched.add_rule(gba, "BA")
	def addClusteringRule(self):
		gcr = GrowthRuleClustering(None)
		self.clusteringsched.add_rule(gcr, "Clustering")
	def runFresh(self, cyclenodes= 0, steps = 0, stepsize = 0, out="hello.gml"):
		if cyclenodes != 0:
			g = nx.cycle_graph(cyclenodes, create_using=memGraph())
		else:
			g = nx.empty_graph(create_using=memGraph())
		self.graphs.append(g)
		self.sched.set_new_network(g)
		self.run(steps, stepsize)
		#nx.write_gml(g, out)
	def run(self, steps = 0, stepsize = 0):
		g = self.graphs[-1]
		dt = datetime.datetime.now()
		self.sched.run(steps, stepsize)
	def addClusteringSched(self, m, p):
		self.clusteringsched = SchedulerBAClustering(m, p)
		self.sched.add_rule(self.clusteringsched)