First time here? Check out the FAQ!

Ask Your Question
1

Translating digraphs in Sage into quivers for QPA

asked 2 years ago

klaaa gravatar image

updated 2 years ago

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 2 years ago

FrédéricC gravatar image

updated 2 years ago

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>
Preview: (hide)
link

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: 2 years ago

Seen: 182 times

Last updated: Apr 26 '22