ValueGraphTransformation::Arithmetic::ArithmeticFunctionFactory#add
behaves like a function factory

creates a function and returns the result node

%3 the function node the result node node0 1337 node3 + node0->node3 node1 42 node1->node3 node2 node3->node2
behaves like a inverse function

returns the inversed function that outputs to vertex 1337.

%3 the function node the result node the inversed function node node0 1337 node3 + node0->node3 node1 42 node1->node3 node4 - node1->node4 node2 node2->node4 node3->node2 node4->node0
behaves like a inverse function

returns the inversed function that outputs to vertex 42.

%3 the function node the result node the inversed function node node0 1337 node3 + node0->node3 node4 - node0->node4 node1 42 node1->node3 node2 node2->node4 node3->node2 node4->node1
ValueGraphTransformation::Arithmetic::ArithmeticFunctionFactory#sub
behaves like a function factory

creates a function and returns the result node

%3 the function node the result node node0 1337 node3 - node0->node3 node1 42 node1->node3 node2 node3->node2
behaves like a inverse function

returns the inversed function that outputs to vertex 1337.

%3 the function node the result node the inversed function node node0 1337 node3 - node0->node3 node1 42 node1->node3 node4 + node1->node4 node2 node2->node4 node3->node2 node4->node0
behaves like a inverse function

returns the inversed function that outputs to vertex 42.

%3 the function node the result node the inversed function node node0 1337 node3 - node0->node3 node4 - node0->node4 node1 42 node1->node3 node2 node2->node4 node3->node2 node4->node1
ValueGraphTransformation::Arithmetic::ArithmeticFunctionFactory#mul
behaves like a function factory

creates a function and returns the result node

%3 the function node the result node node0 13 node3 × node0->node3 node1 a node1->node3 node2 node3->node2
behaves like a inverse function

returns the inversed function that outputs to vertex 13.

%3 the function node the result node the inversed function node node0 13 node3 × node0->node3 node1 a node1->node3 node4 ÷ node1->node4 node2 node2->node4 node3->node2 node4->node0
behaves like a inverse function

returns the inversed function that outputs to vertex a.

%3 the function node the result node the inversed function node node0 13 node3 × node0->node3 node4 ÷ node0->node4 node1 a node1->node3 node2 node2->node4 node3->node2 node4->node1
ValueGraphTransformation::Arithmetic::ArithmeticFunctionFactory#div
behaves like a function factory

creates a function and returns the result node

%3 the function node the result node node0 n node3 ÷ node0->node3 node1 d node1->node3 node2 node3->node2
behaves like a inverse function

returns the inversed function that outputs to vertex n.

%3 the function node the result node the inversed function node node0 n node3 ÷ node0->node3 node1 d node1->node3 node4 × node1->node4 node2 node2->node4 node3->node2 node4->node0
behaves like a inverse function

returns the inversed function that outputs to vertex d.

%3 the function node the result node the inversed function node node0 n node3 ÷ node0->node3 node4 ÷ node0->node4 node1 d node1->node3 node2 node2->node4 node3->node2 node4->node1
ValueGraphTransformation::Arithmetic.apply

It returns a Context

The block is executed within the scope of ArithmeticFunctionFactory.

Arithmetic.apply {
  add(mul(7, 'x'), sub('a', div('42', 'y')), sum(['z', 47, 'u']))
}
%3 node0 7 node3 × node0->node3 node1 x node1->node3 node2 node16 + node2->node16 node3->node2 node4 42 node7 ÷ node4->node7 node5 y node5->node7 node6 node10 - node6->node10 node7->node6 node8 a node8->node10 node9 node9->node16 node10->node9 node11 z node15 + node11->node15 node12 47 node12->node15 node13 u node13->node15 node14 node15->node14 node16->node14

It applies the block operations to the given context

context = Arithmetic.apply {
  add(1337, 42, 'z')
}

Arithmetic.apply(context) {
  mul('x', 'y', 'z')
}
%3 node0 1337 node3 + node0->node3 node1 42 node1->node3 node2 z node3->node2 node4 x node6 × node4->node6 node5 y node5->node6 node6->node2
ValueGraphTransformation::Context

is a Graph

ValueGraphTransformation::Context#function

should fail unless the type is a class that inherits from Function

should fail unless all input objects are Value objects

should fail unless all output objects are Value objects

should return a Function

should connect the input and output vertices

should add the function to the context's list of vertices

ValueGraphTransformation::Context#value_for

should return a Value object

should return the same Value if identifier has been given earlier

should always create new Value objects if nil is given as identifier

ValueGraphTransformation::DotCompiler#to_svg

It compiles the context into a String in svg format.

%3 node0 a node3 + node0->node3 node1 b node1->node3 node2 c node3->node2
ValueGraphTransformation::DotCompiler#to_dot

It compiles the context into a String in dot format.

digraph {
	rankdir="LR" bgcolor="#FFFFFF00";
	node0 [label="a" shape="oval" style="filled" gradientangle="45" width="0.3" height="0.3" fillcolor="white"];
	node1 [label="b" shape="oval" style="filled" gradientangle="45" width="0.3" height="0.3" fillcolor="white"];
	node2 [label="c" shape="oval" style="filled" gradientangle="45" width="0.3" height="0.3" fillcolor="white"];
	node3 [label="+" shape="square" style="filled" width="0.3" height="0.3" fillcolor="white"];
	node0->node3;
	node1->node3;
	node3->node2;
}
ValueGraphTransformation::DotCompiler#vertex_ids

It returns a Hash

Each vertex in the context is mapped to a unique id string

ValueGraphTransformation::DotCompiler#color_map

it returns a Hash.

When there are no vertex selections

each vertex in Context is mapped to default color string

When some vertices are selected

the selected vertices are mapped to the given color string

When a vertex is selected more than once

it is mapped to a string containing all colors separated by a colon

red:green:blue
ValueGraphTransformation::DotCompiler#selection_colors
When there are no vertex selections

it returns an empty hash.

When some vertices are selected

the selected vertices should be keys in the hash.

each value is an Array containing the given color string.

When a vertex is selected more than once

the array should contain color strings from all its selections

ValueGraphTransformation::DotCompiler#propertify

It converts the given Hash to a string in dot property format

Given the hash:

{"property1"=>"foo", "property2"=>"bar"}

The expected string:

property1="foo" property2="bar"
ValueGraphTransformation::DotCompiler#node_properties

returns a Hash with the properties of a vertex

A value node

{"label"=>"a", "shape"=>"oval", "style"=>"filled", "gradientangle"=>45, "width"=>0.3, "height"=>0.3}

A function node

{"label"=>"+", "shape"=>"square", "style"=>"filled", "width"=>0.3, "height"=>0.3}
ValueGraphTransformation::DotCompiler#graph_properties

returns a Hash with the properties of the digraph element

{"rankdir"=>"LR", "bgcolor"=>"#FFFFFF00"}
ValueGraphTransformation::DotCompiler#caption
When there are no vertex selections

It returns an empty string

ValueGraphTransformation::Function

is a Vertex

ValueGraphTransformation::Graph::Graph#add

should return a vertex

should add the vertex to its list of vertices

ValueGraphTransformation::Graph::Graph#connect

should return an edge

should add the edge to its list of edges

should add the edge on the source list of the target vertex

should add the edge on the target list of the source vertex

should fail if source not part of the graph

should fail if target not part of the graph

ValueGraphTransformation::Graph::Graph#delete

should remove the vertex from the graph

ValueGraphTransformation::Graph::Graph#disconnect

should remove the edge from the graph

should remove the edge from the source list of the target vertex

should remove the edge from the target list of the source vertex

ValueGraphTransformation::Graph::Graph#to_dot

should return a String in valid dot format

digraph {
	0;
	1;
	2;
	0->1;
	0->1;
	2->0;
	0->2;
}
ValueGraphTransformation::Value

is a Vertex

ValueGraphTransformation::Graph::Vertex#source_vertices

returns a list of the source vertices

ValueGraphTransformation::Graph::Vertex#target_vertices

returns a list of the target vertices