ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 16 Nov 2016 11:05:37 -0600Edges associated to the variables in G.kirchhoff_symanzik_polynomial()http://ask.sagemath.org/question/35610/edges-associated-to-the-variables-in-gkirchhoff_symanzik_polynomial/ How do the variables t0, t1, t2,... in G.kirchhoff_symanzik_polynomial(), for a given undirected graph G, correspond to the edges of G? (i.e. what is the bijection between the variables ti and the edges of G?) The variables do not follow the same order as in the list G.edges(), which I thought was the case.
Wed, 16 Nov 2016 06:05:38 -0600http://ask.sagemath.org/question/35610/edges-associated-to-the-variables-in-gkirchhoff_symanzik_polynomial/Answer by tmonteil for <p>How do the variables t0, t1, t2,... in G.kirchhoff_symanzik_polynomial(), for a given undirected graph G, correspond to the edges of G? (i.e. what is the bijection between the variables ti and the edges of G?) The variables do not follow the same order as in the list G.edges(), which I thought was the case.</p>
http://ask.sagemath.org/question/35610/edges-associated-to-the-variables-in-gkirchhoff_symanzik_polynomial/?answer=35618#post-id-35618Looking at the source code of the method (see `G.kirchhoff_symanzik_polynomial??`), you see that the following dictionary is used to map integers to edges:
edge2int = {e: j for j, e in enumerate(edges)}
Hence, you can get the correspondence integer -> edges by just typing:
sage: {j: e for j, e in enumerate(G.edges())}
Note however that this behaviour is read from the current source code, but it is not specified in the documentation, so while it is the case now, it might change in the future without warning, so be careful (or request an explicit specification).
Wed, 16 Nov 2016 11:05:37 -0600http://ask.sagemath.org/question/35610/edges-associated-to-the-variables-in-gkirchhoff_symanzik_polynomial/?answer=35618#post-id-35618