Ask Your Question

fidbc's profile - activity

2024-04-12 20:15:37 +0200 received badge  Nice Answer (source)
2024-03-18 10:01:31 +0200 received badge  Nice Answer (source)
2023-07-16 19:47:24 +0200 received badge  Good Answer (source)
2023-05-30 14:38:47 +0200 received badge  Nice Answer (source)
2023-01-10 10:20:26 +0200 received badge  Nice Answer (source)
2022-10-06 03:37:54 +0200 received badge  Nice Answer (source)
2022-08-18 00:15:27 +0200 received badge  Necromancer (source)
2022-01-13 07:29:37 +0200 received badge  Nice Answer (source)
2021-08-11 03:34:01 +0200 received badge  Notable Question (source)
2021-08-11 03:34:01 +0200 received badge  Popular Question (source)
2021-04-19 20:29:39 +0200 received badge  Nice Answer (source)
2021-03-17 19:30:40 +0200 received badge  Popular Question (source)
2020-11-26 17:28:23 +0200 commented question Not getting correct output while computing posets with some conditions.

My impression is that the assumption on the element labels may be causing the unexpected result. That is, P is a list of non-isomorphic posets on 6 elements. So for each poset it contains only one possible labeling.

Perhaps iterating over all possible element labelings for each poset helps?

2020-11-25 13:19:11 +0200 answered a question How to put the drawing of graphs in a matrix or list

I think that the graphs_list.show_graphs is the function you are looking for. Using the notation from above you can execute

sage: graphs_list.show_graphs(glist)

This will display the graphs in glist in blocks of at most 20 graphs. Further details at the user manual.

EDIT: Updated link formatting, link not rendering correctly.

2020-07-19 23:36:52 +0200 received badge  Good Answer (source)
2020-07-16 05:16:59 +0200 received badge  Nice Question (source)
2019-11-12 03:30:14 +0200 received badge  Good Answer (source)
2019-08-27 21:54:11 +0200 received badge  Nice Answer (source)
2019-06-10 16:25:32 +0200 received badge  Nice Answer (source)
2019-03-12 21:11:08 +0200 received badge  Taxonomist
2018-07-01 03:42:10 +0200 commented question How can I change the sage console prompt?

If relevant to anyone with a dark background in their terminal wanting to change the color in the prompt, an option is to go to colors under src/sage/repl/prompts.py. Possible values to return are any of [u'Neutral', u'NoColor', u'LightBG', u'Linux'].

2018-07-01 02:05:01 +0200 commented answer Drawing Auslander-Reiten quivers with sage possible?

You are welcome :-)

2018-04-03 09:35:49 +0200 received badge  Nice Answer (source)
2017-10-11 04:09:17 +0200 edited question What are the following commands telling us? R=Integers() [R.ideal([a,b]) == R.ideal([gcd(a,b)]) for a in range(1,20) for b in range(1,20)]

What are the following commands telling us?

R=Integers()
[R.ideal([a,b]) == R.ideal([gcd(a,b)]) for a in range(1,20) for b in range(1,20)]
2017-10-08 22:58:45 +0200 commented answer Finding all simply laced Dynkin graphs with a given number of vertices up to isomorphism

@maresage Would you please be so kind to try and donate via paypal to the address listed here? This info is also available here(They're collecting money for helping repair damage from the quake in Oaxaca). If this is not possible, then donating to sagemath would be nice. You can donate through the top right link at sagemath.org or via this direct link. You may contact me via the fidelbarrera+asksage gmail account for the receipt or to let me know if none of this worked. Thanks!

2017-10-06 19:12:15 +0200 answered a question Finding all simply laced Dynkin graphs with a given number of vertices up to isomorphism

Here is some code that might do the job. Please feel free to test it and let me know if this works.

def directg(g6):
    import subprocess
    sp = subprocess.Popen("directg -o", shell=True,
                          stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                          stderr=subprocess.PIPE, close_fds=True)
    stdout = sp.communicate(input='{0}\n'.format(g6))[0]
    d6_strings = stdout.split()
    for d6 in d6_strings:
        yield DiGraph(d6[1:])

def A_base(n):
    return graphs.PathGraph(n).graph6_string()

def D_base(n):
    g = graphs.PathGraph(n-1)
    g.add_edge(n-3,n-1)
    return g.graph6_string()

def E_base(n):
    g = graphs.PathGraph(n-1)
    g.add_edge(2,n-1)
    return g.graph6_string()

def generate_DynkinQuivers(n,kind='A'):
    if kind not in 'AED':
        raise ValueError("Invalid type of Dynkin quiver, should be one of 'A', 'D' or 'E'.")
    if kind == 'A':
        g6_base = A_base(n)
    elif kind=='D':
        g6_base = D_base(n)
    elif kind=='E':
        g6_base = E_base(n)
    output_template = 'DynkinQuiver("{kind}",{size},[{orientation}])'

    for digraph in directg(g6_base):
        orientation = []
        for i in range(n-2):
            if digraph.has_edge(i,i+1):
                orientation.append('"r"')
            elif digraph.has_edge(i+1,i):
                orientation.append('"l"')
            else:
                raise ValueError("Format conversion error.")
        if kind in 'AD':
            if kind=='A':
                other = n-2
            else:
                other = n-3
            if digraph.has_edge(other,n-1):
                orientation.append('"r"')
            elif digraph.has_edge(n-1,other):
                orientation.append('"l"')
            else:
                raise ValueError("Format conversion error. Last edge of kind {0} quiver.".format(kind))
        if kind =='E':
            if digraph.has_edge(n-1,2):
                orientation.append('"d"')
            elif digraph.has_edge(2,n-1):
                orientation.append('"u"')
            else:
                raise ValueError("Format conversion error. Last edge of kind E quiver.")
        yield output_template.format(kind=kind,size=n,orientation=','.join(orientation))
def DynkinQuivers(n,kind='A'):
    return '[{0}]'.format(','.join(generate_DynkinQuivers(n,kind)))

Sample usage:

DynkinQuivers(3,'A')

produces

'[DynkinQuiver("A",3,["r","r"]),DynkinQuiver("A",3,["r","l"]),DynkinQuiver("A",3,["l","r"])]'

Which can be saved to a file.

It takes about half a second to go up to n=13

%time
output=DynkinQuivers(13,'E')
CPU time: 0.41 s, Wall time: 0.53 s
2017-10-06 18:29:04 +0200 commented question Finding all simply laced Dynkin graphs with a given number of vertices up to isomorphism

Guess the purpose of $E_n$ is having the $n$-th vertex anchored at the third vertex of the path from left to right, correct?

2017-10-06 18:27:58 +0200 commented question Finding all simply laced Dynkin graphs with a given number of vertices up to isomorphism

What exactly do we mean by "fast code"? Any memory usage constraints? Is a 1 minute wait reasonable for $n=13$?

2017-10-06 18:02:42 +0200 commented question Finding all simply laced Dynkin graphs with a given number of vertices up to isomorphism

Is $E_n$ defined for all $n\geq 6$? Or is it just for $n\in{6,7,8}$?

2017-09-27 23:33:28 +0200 commented question How to run maple in cocal?

Provided you manage to install it, it might be possible.

2017-09-24 23:34:55 +0200 commented question Finding posets of a certain form 2

Depending on what you are planning to do with these posets, it might be worth filtering them up to a certain size and store the output. So that you can just go back and read from the stored list. However, if you are interested in say, counting them, then maybe generating them will be the way to go.

2017-09-24 23:31:52 +0200 commented question Finding posets of a certain form 2

This looks like a very particular set of posets. Maybe you'll need to generate them manually if you do not want to filter from the list of all posets.

2017-09-24 23:09:02 +0200 commented question Finding posets of a certain form 2

By Hasse quiver, do you mean Hasse diagram?

If so, then you may use the DiGraph methods on the diagram to check the out-degree and the in-degree. See for example out_degree and in_degree.

2017-09-24 23:05:14 +0200 edited question Finding posets of a certain form 2

I try to obtain the connected posets with n elements having a top and bottom such that in the Hasse quiver, in every point there start at most two arrows and at every point there end at most two arrows (thus for example all distributive lattices are of this form). Is there a quick command to obtain this as a list? What condition does one has to add in

posets = [ p for p in Posets(n) if p.is_connected() and p.has_top() and p.has_bottom()]

Actually a quick method would be cool which works up to n=10 or 11. (filtering things out of the set of all posets, seems to be very slow in SAGE)

2017-09-24 23:01:36 +0200 commented answer Output too long in SAGE

@maresage L[0:40] will output all elements in L with indices i such that 0<=i<40. Thus L[40] will not be contained in L[0:40]. However L[40:80] will contain L[40].

2017-09-24 02:57:22 +0200 commented question Output too long in SAGE

[Bug report (?)] Should P.is_lattice be P.is_lattice() in the second to last line in the code above?

2017-09-24 02:54:27 +0200 answered a question Output too long in SAGE

To save to a file, you may try the following.

with open('filename.txt','w') as outfile:
    outfile.write("{0}\n".format(what_you_want(8)))

Searching for "write to file in python" might give some insight into this aspect of Python.

If you wish to process a list by chunks, then looking up "slicing in Python" might be useful. Given a list L, you may access the second chunk of length 40 by using L[40:80]. So using slicing within a for loop could produce the desired result.

2017-09-23 07:20:07 +0200 answered a question Call error for integers (when I haven't declared any.)

Your code contains syntax errors. One of the problems seems to be:

sin^2(j*2*pi/N)

This is being interpreted as sin^(2(j*2*pi/N)), which is problably not what you meant. Did you mean sin(j*2*pi/N)^2?

Seems like this is the only error.

2017-09-22 12:29:43 +0200 answered a question Stochastic block model

Assuming the input consists of n, r, and the probabilities for edges within a community; and assuming that the probability of edges between vertices in different communities is 0, then here is a possible way to generate such a graph.

community_sizes = Partitions(n,length=r).random_element()
H = Graph()
for comm_size,Pr in zip(community_sizes,probs):
    H=H.disjoint_union(graphs.RandomGNP(comm_size,Pr),labels='integers')

This is assuming that n, r and probs (assumed to be a list of length r containing $P_1,P_2,\ldots,P_r$) are given as part of the input. To see the resulting graph you can use H.show().

2017-09-22 12:06:05 +0200 commented question Stochastic block model

Are the sizes of the communities given as part of the input? Maybe this is what the comment above is trying to address.

Is the probability of edges between vertices in different communities equal to 0?