当前位置: 首页>>代码示例>>Python>>正文


Python Graph.savesvg方法代码示例

本文整理汇总了Python中Graph.savesvg方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.savesvg方法的具体用法?Python Graph.savesvg怎么用?Python Graph.savesvg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Graph的用法示例。


在下文中一共展示了Graph.savesvg方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: FSM

# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import savesvg [as 别名]
class FSM(object):
	def __init__(self):
		self.name = "go"
		self.actionset = []
		self.startstates = []
		self.edgeset = []
		self.cases = []
		self.g = None

	def generateEdgeByState(self, state):
		untracked = [state]
		tracked = []
		edgset = [] 
		while(len(untracked) > 0):
			midstates = []
			state = untracked.pop()
			tracked.append(state)
			for action in self.actionset:
				#get new status
				newsta = action.transfer(copy.deepcopy(state))
				#get new edge
				edge = Edge(state,newsta, 0, action)

				#add to edge set if it's new
				
				if not edge in edgset:
					edgset.append(edge)

				#add to midstatus set if it's a new state
				if not newsta in tracked and not newsta in midstates:
					midstates.append(newsta)
			untracked = midstates
		return edgset
	
	def generateEdge(self):
		#generate all edges
		for start in self.startstates:
			self.edgeset += self.generateEdgeByState(start)
		self.edgeset = list(set(self.edgeset))

	def explore(self):
		self.g = Graph()

		#generate all edges
		self.generateEdge()
		#add all edges in graph
		self.g.addEdge(self.edgeset)
		#set start states 
		self.g.setVexPtype(self.startstates, 1)

		self.g.eulerize()
		edges = self.g.getEurlerCircuit()
		'''
		print "===========Eu=========="
		self.g.outputpath(edges)
		print "===========End========="
		'''
		self.cases = self.g.getPathSet(edges)
	def execute_one(self, case):
		for edge in case:
			print "executing " + edge.action.name + " ... ..."
			if not edge.action.execute():
				return False
		return True
	def execute(self):
		for case in self.cases:
			print "=============Execution================"
			result = self.execute_one(case)
			print("================%s=================" % str(result) )
		
	def dumpcase(self):
		i = 0
		for case in self.cases:
			print("Case " + str(i) + ": " ),
			self.g.outputpath(case)
			i+=1
	def savesvg(self):
		self.g.savesvg()
开发者ID:roynwang,项目名称:mbt_test,代码行数:80,代码来源:FSM.py


注:本文中的Graph.savesvg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。