s = "SAAAEBBBT"
t = "TAAAEBBBS"
g = graphDFS("".join("[%s]" % a for a in s))
g.print()
goal = graphDFS("".join("[%s]" % a for a in t))
goal.print()

aJump = ruleGMLString("""rule [
	ruleID "A Jump"
	left [
	
	context [
	]
	right [
	]
]""")
bJump = ruleGMLString("""rule [
	ruleID "B Jump"
	left [
	]
	context [
	]
	right [
	]
]""")
aMove = ruleGMLString("""rule [
	ruleID "A Move"
	left [
	]
	context [
	]
	right [
	]
]""")
bMove = ruleGMLString("""rule [
	ruleID "B Move"
	left [
	]
	context [
	]
	right [
	]
]""")
for a in inputRules: a.print()

dg = DG(graphDatabase=inputGraphs)
dg.build().execute(addSubset(g) >> repeat(inputRules))

p = DGPrinter()
p.graphvizPrefix=' layout = "dot"; '

def setPrinter(p):
	p.withRuleName = True
	p.pushVertexColour(lambda a: "blue" if a.graph == g else "")
	p.pushVertexColour(lambda a: "red" if a.graph == goal else "")
setPrinter(p)
dg.print(p)

# The following is a rather brutal sledgehammer-approach.
#
# You could also use, e.g., networkx to find a shortest path
# in the derivation graph, as the derivation graph is very
# likely a directed graph (i.e., not a hyper.graph)
flow = Flow(dg)
flow.addSource(g)
flow.addSink(goal)
flow.addConstraint(inFlow(g) == 1)
flow.setSolverEnumerateBy(absGap=0)
flow.calc()
fp = FlowPrinter()
setPrinter(fp.dgPrinter)
for s in flow.solutions:
	s.print(fp)
