本文整理汇总了Python中Graph.outputpath方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.outputpath方法的具体用法?Python Graph.outputpath怎么用?Python Graph.outputpath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph.outputpath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FSM
# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import outputpath [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()