corrected bug in addgraph, to be further tested