adds graph2 function - inline version of graph