moved common code from definitions.php to functions.graph.php