1 | initial version |
I've got the answer from Dr. Dima Pasechnik, in Sage-Support Google group. Thanks to him!
Some string manipulations and functional programming operators do the job:
sage: macaulay2('loadPackage "Graphs"')
sage: G = Graph({1:[2], 2:[1,3], 3:[2,4], 4:[3]})
sage: macaulay2('H = graph({'+','.join(map(lambda (x,y,_): '{'+str(x)+','+str(y)+'}', G.edges()))+'})')