public double messageFactor2Node(int factor, int node, int value) {
		double result = 0;
		if (factor == node) {
			return potentials.potential(node, value);
		}
		else if (factor == potentials.chainLength() + node -1) {
			// left factor n' -> f -> n
			for (int v = 1; v <= potentials.numXValues(); v++) {
				result += potentials.potential(factor, v, value) * messageNode2Factor(factor, node-1, v);
			}
		}
		else if (factor == potentials.chainLength() + node) {
			// left factor n <- f <- n'
			for (int v = 1; v <= potentials.numXValues(); v++) {
				result += potentials.potential(factor, value, v) * messageNode2Factor(factor, node+1, v);
			}
		}
		else {
			// they are not connected
			return 1;
		}
		
		return result;
	}