# Translating digraphs in Sage into quivers for QPA

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 close merge delete

Sort by » oldest newest most voted

Like this

def _libgap_(self):
"""
self = a directed graph with vertices 0, ... , n-1
"""
from sage.libs.gap.libgap import libgap
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>

more