Thank you sir! I am new to these string manipulations, it worked like a 
charm!
Maybe there is a shorter way to do this, but as I've learned from you, I 
did the following:

macaulay2('loadPackage "Graphs"')
G = Graph({1:[2], 2:[1,3], 3:[2,4], 4:[3]})
E=G.edges()
macaulay2('EG={}')
for i in range(len(E)):
               macaulay2('e={}')
               macaulay2('e=append(e,'+str(E[i][0])+')')
               macaulay2('e=append(e,'+str(E[i][1])+')')
               macaulay2('EG=append(EG,e)')
macaulay2('H = graph(EG)')

Now it seems easier for ideals. Thank you again! :)


30 Haziran 2016 Perşembe 13:11:25 UTC+3 tarihinde Dima Pasechnik yazdı:
>
> Basically, you need to build, in Sage, a string to pass to M2. E.g.:
>
> sage: a=1; b=31; macaulay2('G = 
> graph({{'+str(a)+',2},{2,'+str(b)+'},{'+str(b)+',4}})')
> Graph{1 => {2}    }
>       2 => {1, 31}
>       4 => {31}
>       31 => {2, 4}
>
> Ideally, you'd develop methods for Sage types to convert them to M2 types.
> So that macaulay2(G) would create a handle to a M2 object which is an M2 
> graph.
> Currently there are such functions for rings, polynomials, and ideals:
>
> sage: R2 = macaulay2.ring('QQ', '[x, y]'); R2            # optional - 
> macaulay2QQ[x..y, Degrees => {2:1}, Heft => {1}, MonomialOrder => 
> {MonomialSize => 16}, DegreeRank => 1]                                        
>                  {Lex => 2          }                                         
>                 {Position => Up    }sage: I = macaulay2.ideal( ('y^2 - x^3', 
> 'x - y') ); I   # optional - macaulay2
>
>
>
>  
>
> On Thursday, June 30, 2016 at 9:36:19 AM UTC+1, [email protected] 
> wrote:
>>
>> 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 link:
>>
>> http://math.uiuc.edu/Macaulay2/doc/Macaulay2-1.8.2/share/doc/Macaulay2/Graphs/html/_graph.html
>> 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
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to