Relations defined by graphs and equations