Ask Your Question

G-Sage's profile - activity

2020-11-21 11:10:05 +0200 received badge  Notable Question (source)
2020-06-03 07:44:06 +0200 received badge  Famous Question (source)
2020-01-04 14:58:19 +0200 received badge  Notable Question (source)
2019-06-11 02:49:09 +0200 received badge  Popular Question (source)
2019-06-09 14:18:26 +0200 received badge  Famous Question (source)
2019-06-09 14:18:25 +0200 received badge  Notable Question (source)
2019-01-08 20:22:21 +0200 received badge  Notable Question (source)
2018-04-12 16:07:01 +0200 received badge  Nice Question (source)
2018-03-14 17:16:56 +0200 received badge  Notable Question (source)
2018-01-21 17:24:55 +0200 received badge  Notable Question (source)
2017-10-19 09:50:13 +0200 received badge  Nice Question (source)
2017-08-05 21:44:12 +0200 received badge  Notable Question (source)
2017-06-10 16:04:05 +0200 received badge  Famous Question (source)
2017-05-22 21:16:50 +0200 received badge  Famous Question (source)
2016-07-20 11:02:45 +0200 received badge  Nice Question (source)
2016-07-20 09:48:12 +0200 received badge  Notable Question (source)
2016-07-20 09:48:12 +0200 received badge  Famous Question (source)
2016-07-20 09:47:56 +0200 received badge  Popular Question (source)
2016-07-20 09:47:53 +0200 received badge  Popular Question (source)
2016-07-20 09:47:49 +0200 received badge  Famous Question (source)
2016-07-20 09:46:05 +0200 received badge  Nice Question (source)
2016-07-20 09:37:28 +0200 received badge  Popular Question (source)
2016-07-20 09:36:06 +0200 received badge  Famous Question (source)
2016-07-20 09:31:12 +0200 received badge  Popular Question (source)
2016-07-20 09:31:12 +0200 received badge  Notable Question (source)
2016-06-26 18:27:01 +0200 received badge  Popular Question (source)
2016-06-23 17:15:00 +0200 received badge  Popular Question (source)
2016-06-01 21:39:02 +0200 received badge  Popular Question (source)
2016-05-31 00:05:20 +0200 received badge  Nice Question (source)
2016-05-31 00:05:16 +0200 marked best answer Editing entries of matrix

I'm looking at a matrix, say adjacency matrix of a graph, I want to change some of the entries now. I am told it's a vector and it's immutable. What can I do?

One thought I had is adding some other matrix to it with only one nonblank entry. But, is there some easy way to do that?

Another thought I had was turning it into a list, list( Maybe that's acceptable. I'm not 100% sure yet for what I'm working on. If I go that way, is there a way to print it in a matrix form again, i.e., entries print in a square shape.

Thanks for any help

2016-05-03 01:52:39 +0200 received badge  Famous Question (source)
2016-03-13 10:54:23 +0200 received badge  Notable Question (source)
2016-02-24 13:40:20 +0200 received badge  Famous Question (source)
2016-01-04 17:41:17 +0200 received badge  Notable Question (source)
2015-12-30 02:57:03 +0200 received badge  Famous Question (source)
2015-12-01 15:40:35 +0200 received badge  Notable Question (source)
2015-11-04 07:33:17 +0200 received badge  Famous Question (source)
2015-07-03 15:29:12 +0200 received badge  Notable Question (source)
2015-06-21 20:25:46 +0200 received badge  Famous Question (source)
2015-04-01 21:10:39 +0200 received badge  Popular Question (source)
2015-03-27 04:12:18 +0200 marked best answer Printing in different colors in notebook

That's it. Instead of

print "Hello world"

and getting the output in the standard blue (in the notebook), I want to have a different color sometime. Is this possible? Much love.

2015-03-27 04:12:15 +0200 marked best answer Strategies for drawing good graphs (graph theory)

Okay, if I want to have a nice drawing of a 5-cycle, it's built in. If I do

g = graphs.CycleGraph(5)

it automatically draws it in a nice way. But, if I am looking at some random graph of order 11 that I want a nice picture of, for my dissertation, how am I supposed to get a nice picture? According to my question here, kcrisman says the graph editor is broken. That would have been a nice tool. My current strategy is to repeatedly have it show the graph and save it as a pdf until it gets into the format I want, i.e., run the following code over and over.

graph_plot = g.plot(vertex_colors={'white'})'graph.pdf')

But, this doesn't always end up with the picture I really want. And, occasionally I want to do something like delete a vertex and draw the graph again, but now all of the sudden the plot behaves completely differently and it never looks anything like the previous drawing minus one vertex.

So, what are some ways to get around this?

2015-03-27 04:12:07 +0200 marked best answer Memory blowup 2

This code in Sage 4.8 (with CPlex installed if that matters) uses a lot of memory. After around 36 million graphs, it is using around 21 Gigs:

for g in graphs.nauty_geng("11"):
    ind_set = g.independent_set()
2015-03-27 04:12:00 +0200 marked best answer Learning Python for Sage

Hi, I'm no expert in Python or Sage, but I want to learn Python specifically to help with Sage. I bought a book on Python programming and I'm trying out some of the stuff in Sage. But, some of it doesn't seem to work. So, I'm wondering... is this because Sage doesn't use Python 3 yet, or are there just some things with Python that don't work in Sage? If it's the second one, how can I know what's going to work and what's not? For example, in the book I have it says I should be able to do:

print("stuff stuff", end = " ")
print("stuff stuff")

and the effect is that instead of ending the print statement with "\n", it ends with a space so the second print statement prints on the same line. But, doing this in Sage 4.7 results in a syntax error, and it appears to not like the =.


2015-03-27 04:11:57 +0200 marked best answer Writing data to file

This is all in the Sage Notebook:

I want to store some data in a file, Excel or Access or something, because that's what I know. I am using statements like o.write("something" + ", " + "something" + "\r") and I'm doing this in a loop. I'm writing it to a txt file. So, Sage does its thing and there's the little "stuff.txt" link I can click on afterward. I click on it and it looks just how I want it. Then, using Firefox 6.whatever is out these days, I do file save as and save it as stuff.txt. I open it and there are no line breaks at all and the data is pretty much useless. I also tried "\n" and same thing.

I found a sort of solution, because I could use "stuff.csv" instead and it mostly works right. The problem there is, I have data which has commas in it. So, I was hoping to do a .txt file using tab delimited so the commas in the data didn't cause problems. But, the above problem for .txt files exists and I don't know how to fix it.

Oh, also just copying and pasting the data from the file Sage creates (before saving it using Firefox) didn't work today when I had nearly 300,000 lines of data. Excel/Access have the "[Not responding]" message, even though Excel and Access can easily handle 300,000 lines of data. Perhaps it is the clipboard is not big enough for that? I don't know.

Any ideas? Thanks for your help!

2015-03-27 04:11:56 +0200 marked best answer Graph minor code (too slow in certain situations) Sage 4.6

Okay, so what I want to say here is that the code that searches for a graph minor is extremely slow in situations where it should be able to respond instantaneously. Here's a function written by DSM when responding to my last question here:

def has_minor(G, H):
        m = G.minor(H)
        return True
    except ValueError: 
        return False

I run the following code:

print h.size()
print g.size()

This code checks if a K_{4,4} graph has as a minor a K_7 graph. The output is:


This tells us that a K_7 has 21 edges and a K_{4,4} has 16, so there's no way that a K_{4,4} has as a minor a K_7. Minors must have less than or the same number of edges as the original graph. So, it shouldn't take almost a minute to tell me that there is no such minor. It should take 0.001 seconds, approximately, because it should first check that simple thing before actually trying to find minors.

Or, am I completely off here?

2015-03-27 04:10:26 +0200 marked best answer Vertex connecitivity incomplete (pun intended)

I am no graph theory expert, but the textbook I am learning from, and the Wikipedia article "Connecitivy (graph theory)" (which doesn't use my book as a reference, i.e., there are at least 2 books saying this) both say the vertex connectivity of a complete graph on n vertices is n-1. But, if you try to do graphs.CompleteGraph(whatever).vertex_connectivity(), it says

"There can be no vertex cut in a complete graph."

I looked at the code, and the fix is simple: Take

if g.is_clique():
    raise ValueError("There can be no vertex cut in a complete graph.")

and make it

if g.is_clique():
    return g.order()-1

But, I don't know how this fixing stuff works.

Second question, why does it return answers in the form 1.0 when the only possible values of this are integers?

Thirdly, there are a couple typos in the commenting of the code:

In a grid, the vertex connectivity is equal to the minimum degree, in which case one of the two sets it of cardinality 1::

should be "two sets IS of"

For directed graphs, the strong connexity is tested through the dedicated function::

I believe should be "strong vertex connectivity". Maybe connexity is okay but I am guessing it's a typo.

Fourthly, can we make "graph theory" a tag?

2015-03-27 04:09:51 +0200 marked best answer Graph minors in programming


In a program I am writing, I need to know whether or not one graph is a minor of another, True or False. The function g.minor(h) returns the parts of g that are the minor h, if it exists, something like this:

{0: [2], 1: [1], 2: [0], 3: [3, 6], 4: [4], 5: [5]}

UPDATE: I think I can handle this but I'm sure it's not the best way, so any help is still appreciated. By doing L = g.minor(h) and then testing if len(flatten(L.values())) > 0, I will get True if h is a minor of g (or so it seems).

If no such minor exists, it throws an error. To be specific, it says "Traceback", then several lines of stuff I don't get at all, and then "ValueError: This graph has no minor isomorphic to H !". I don't know how to deal with either of these situations really. Can you help me out? Again, I just want True in the first case and False in the second case for programming purposes, as in graph theory knowing if a graph has another graph as a minor is very important in many instances.

I am using Version 4.6 (since I am a Windows user), in case that matters.

Thanks for any help!

2015-03-27 04:08:51 +0200 marked best answer Fonts in graph (graph theory) pictures are Type 3???

I am writing my thesis. One requirement is I can not have any Type 3 fonts. My document does have Type 3 fonts (Go to File, Properties, then the Font tab in Adobe Reader to check) and I believe it is caused by the graphs I have drawn with Sage, which I save as PDFs and then include with \includegraphics in LaTeX. For example:

g.relabel(lambda i: i+1)
graph_plot = g.plot(talk=True)'5cycle.pdf')

It is listed as "BitstreamVeraSans-Roman". I am using the thesis LaTeX template provided by my university, and I have not added any statements that tell it to use a certain font anywhere, so I don't think it's possible that the Type 3 font is anywhere in my text, unless the person who made the template is a jerk.

That left me to guess it is in my pictures. I googled "bistream verasans roman sage" and came across this question which suggests it is possible. I also deleted out 70% of my thesis, starting from the spot where the first figure appears, so that I deleted out all figures created as PDFs in Sage. And, now there are no Type 3 fonts.

Is it possible to change the font used? I guess it is the font used in labeling the vertices of the graphs??? Or, is it possible to explain why these fonts were used so I can try to explain why these fonts will not cause a problem? The reason we can not use Type 3 fonts is because this website says they cause problems, essentially that Type 1 fonts appear nicer when you are reading it on the screen.