'''
Created on Jan 30, 2017

@author: amzvja
'''
from miniflow.Add import Add
from miniflow.Input import Input
from miniflow.Mul import Mul
from miniflow.Util import topological_sort, forward_pass

"""
This script builds and runs a graph with miniflow.

There is no need to change anything to solve this quiz!

However, feel free to play with the network! Can you also
build a network that solves the equation below?

(x + y) + y
"""



x, y, z = Input(), Input(), Input()

f = Add(x, y, z)

feed_dict = {x: 10, y: 5, z: 20}

sorted_nodes = topological_sort(feed_dict)
output = forward_pass(f, sorted_nodes)

# NOTE: because topological_sort set the values for the `Input` nodes we could also access
# the value for x with x.value (same goes for y).
print("{} + {} = {} (according to miniflow)".format(feed_dict[x], feed_dict[y], output))
