Ask Your Question

Mehmet Akif Yetim's profile - activity

2016-07-01 02:37:34 +0200 answered a question How to convert (some particular) Sage objects into Macaulay2 ones

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()))+'})')

2016-06-30 14:46:06 +0200 asked a question How to convert (some particular) Sage objects into Macaulay2 ones

Hi,

I do some calculations about graphs and ideals via M2 interface of Sage or just using M2, but for that, I have to use M2 input as below:

sage: macaulay2('loadPackage "Graphs"')

sage: macaulay2('G = graph({{1,2},{2,3},{3,4}})')

as explained in the Macaulay2 web page.

Is there a way to convert a graph or an ideal written in Sage code into Maculay2 ones so that it can be employed in M2 interface. For instance,

sage: d={1:[2], 2:[1,3], 3:[2,4], 4:[3]}

sage: G = Graph(d)

sage: macaulay2('H=graph(G)') (or H=macaulay2('graph(G)'))

Of course M2 won't accept my silly code in the 3rd line, but I've tried various ways like injecting a square free-quadratic-monomial ideal or edge list of a graph into M2 and I always fail. I also have the same problem for ideals.

It's a long-standing problem of mine and it costs me writing heavy codes in Sage for multiple calculations. Calculating via M2 with Sage inputs will save lots of my time.

Can anyone help?

Thanks in advance! :)

Best Regards

Mehmet