Ask Your Question
1

Translating digraphs in Sage into quivers for QPA

asked 2022-04-25 22:42:06 +0200

klaaa gravatar image

updated 2022-04-25 22:44:54 +0200

Given a digraph in Sage as follows:

[(0, 4), (3, 2), (4, 5), (5, 1), (5, 3)]

Question: Is it possible using Sage to automatically obtain this digraph as a quiver readable for the GAP-package QPA?

The above example should have the following form readable for QPA:

Q:=Quiver(6,[[1,5,"x1"],[5,6,"x2"],[6,2,"x3"],[6,4,"x4"],[4,3,"x5"]]);

Here 6 is the number of vertices and the xi are the names of the arrows. For QPA one has to label the vertices starting with 1 (0 is not allowed). Thus I added +1 to every vertex in the Sage labeling.

I wonder whether there is an easy trick to translate the Sage ouput of digraphs directly to quivers readable for QPA.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2022-04-26 12:43:33 +0200

FrédéricC gravatar image

updated 2022-04-26 20:10:06 +0200

Like this

def _libgap_(self):
    """
    self = a directed graph with vertices 0, ... , n-1
    """
    from sage.libs.gap.libgap import libgap
    libgap.LoadPackage("QPA")
    L = [(x + 1, y + 1, f"x_{i + 1}")
         for i, (x, y) in enumerate(self.edges(labels=False))]
    return libgap.Quiver(self.num_verts(), L)

example

sage: G = DiGraph([(0, 4), (3, 2), (4, 5), (5, 1), (5, 3)])
sage: _libgap_(G)
<quiver with 6 vertices and 5 arrows>
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2022-04-25 22:42:06 +0200

Seen: 53 times

Last updated: Apr 26