ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 31 Dec 2011 20:34:27 +0100Show function for graphs is not working!https://ask.sagemath.org/question/8565/show-function-for-graphs-is-not-working/Hi everyone,
Yesterday I wrote a code to generate a random semi-regular graph. The algorithm works in this way:
1)It chooses vertices in numerical order
2)in each step it looks to see if the degree of the vertex is larger or smaller than the specified value
for that vertex(which is a for first N/2 and b for second N/2 vertices)
3)it randomly adds an edge or remove one until the degree of vertex become acceptable
4)switches to the next vertex.
However when I use show() function to see what is happening in each step, the result is frustrating,
the Show() function shows a graph like what it should but the degrees are not associated with the
correct vertices!
for example most of the time even in the first cycle of the while loop, it should assign 3 edges
to the '0' vertex. When I print the neighbours of '0' with "print G[0]" I get '[1,3,4]' but then in the
plotted graph neighbours of '0' are '1' and '2' and '5'. I don't understand what is wrong with this
Sage?!
I am really exhausted of trying!
My code is at:
http://www.4shared.com/file/ZKT9x0W2/Generating_Regular_Graphs.html
Thanks a lot for the helps...
Fri, 16 Dec 2011 06:14:46 +0100https://ask.sagemath.org/question/8565/show-function-for-graphs-is-not-working/Answer by Naji for <p>Hi everyone,</p>
<p>Yesterday I wrote a code to generate a random semi-regular graph. The algorithm works in this way:
1)It chooses vertices in numerical order
2)in each step it looks to see if the degree of the vertex is larger or smaller than the specified value
for that vertex(which is a for first N/2 and b for second N/2 vertices)
3)it randomly adds an edge or remove one until the degree of vertex become acceptable
4)switches to the next vertex.
However when I use show() function to see what is happening in each step, the result is frustrating,
the Show() function shows a graph like what it should but the degrees are not associated with the
correct vertices!
for example most of the time even in the first cycle of the while loop, it should assign 3 edges
to the '0' vertex. When I print the neighbours of '0' with "print G[0]" I get '[1,3,4]' but then in the
plotted graph neighbours of '0' are '1' and '2' and '5'. I don't understand what is wrong with this
Sage?!
I am really exhausted of trying!
My code is at:
<a href="http://www.4shared.com/file/ZKT9x0W2/Generating_Regular_Graphs.html">http://www.4shared.com/file/ZKT9x0W2/...</a></p>
<p>Thanks a lot for the helps...</p>
https://ask.sagemath.org/question/8565/show-function-for-graphs-is-not-working/?answer=13022#post-id-13022Solved!
My code has a bug!
However I want to mention it is really annoying that the bug of my code results in
a bug of show function for SAGE!!
Thanks anyway!Fri, 16 Dec 2011 06:55:04 +0100https://ask.sagemath.org/question/8565/show-function-for-graphs-is-not-working/?answer=13022#post-id-13022Comment by Jason Grout for <p>Solved!
My code has a bug!
However I want to mention it is really annoying that the bug of my code results in
a bug of show function for SAGE!!</p>
<p>Thanks anyway!</p>
https://ask.sagemath.org/question/8565/show-function-for-graphs-is-not-working/?comment=20700#post-id-20700Can you elaborate on what the bug in your code was, and exactly how that was exposing a bug in the show function? We definitely want to fix any bugs in show.Fri, 16 Dec 2011 09:43:14 +0100https://ask.sagemath.org/question/8565/show-function-for-graphs-is-not-working/?comment=20700#post-id-20700Comment by DSM for <p>Solved!
My code has a bug!
However I want to mention it is really annoying that the bug of my code results in
a bug of show function for SAGE!!</p>
<p>Thanks anyway!</p>
https://ask.sagemath.org/question/8565/show-function-for-graphs-is-not-working/?comment=20699#post-id-20699Try refreshing the page in your browser; it looks to me like a caching problem. I can reproduce this and am pushing it up to sage-devel.Fri, 16 Dec 2011 10:42:01 +0100https://ask.sagemath.org/question/8565/show-function-for-graphs-is-not-working/?comment=20699#post-id-20699Answer by Jason Grout for <p>Hi everyone,</p>
<p>Yesterday I wrote a code to generate a random semi-regular graph. The algorithm works in this way:
1)It chooses vertices in numerical order
2)in each step it looks to see if the degree of the vertex is larger or smaller than the specified value
for that vertex(which is a for first N/2 and b for second N/2 vertices)
3)it randomly adds an edge or remove one until the degree of vertex become acceptable
4)switches to the next vertex.
However when I use show() function to see what is happening in each step, the result is frustrating,
the Show() function shows a graph like what it should but the degrees are not associated with the
correct vertices!
for example most of the time even in the first cycle of the while loop, it should assign 3 edges
to the '0' vertex. When I print the neighbours of '0' with "print G[0]" I get '[1,3,4]' but then in the
plotted graph neighbours of '0' are '1' and '2' and '5'. I don't understand what is wrong with this
Sage?!
I am really exhausted of trying!
My code is at:
<a href="http://www.4shared.com/file/ZKT9x0W2/Generating_Regular_Graphs.html">http://www.4shared.com/file/ZKT9x0W2/...</a></p>
<p>Thanks a lot for the helps...</p>
https://ask.sagemath.org/question/8565/show-function-for-graphs-is-not-working/?answer=13031#post-id-13031Please see [this discussion on sage-devel](https://groups.google.com/forum/#!topic/sage-devel/JwZbt0ltELk) for discussion about this bug in the notebook and a resolution to the problem.Fri, 16 Dec 2011 12:54:17 +0100https://ask.sagemath.org/question/8565/show-function-for-graphs-is-not-working/?answer=13031#post-id-13031Answer by Naji for <p>Hi everyone,</p>
<p>Yesterday I wrote a code to generate a random semi-regular graph. The algorithm works in this way:
1)It chooses vertices in numerical order
2)in each step it looks to see if the degree of the vertex is larger or smaller than the specified value
for that vertex(which is a for first N/2 and b for second N/2 vertices)
3)it randomly adds an edge or remove one until the degree of vertex become acceptable
4)switches to the next vertex.
However when I use show() function to see what is happening in each step, the result is frustrating,
the Show() function shows a graph like what it should but the degrees are not associated with the
correct vertices!
for example most of the time even in the first cycle of the while loop, it should assign 3 edges
to the '0' vertex. When I print the neighbours of '0' with "print G[0]" I get '[1,3,4]' but then in the
plotted graph neighbours of '0' are '1' and '2' and '5'. I don't understand what is wrong with this
Sage?!
I am really exhausted of trying!
My code is at:
<a href="http://www.4shared.com/file/ZKT9x0W2/Generating_Regular_Graphs.html">http://www.4shared.com/file/ZKT9x0W2/...</a></p>
<p>Thanks a lot for the helps...</p>
https://ask.sagemath.org/question/8565/show-function-for-graphs-is-not-working/?answer=13083#post-id-13083@Jason Grout:
Sorry for the late reply I didn't notified. I just see it accidentally here!
I find out if your code is buggy(not related to show necessarily) it could result in malfunctioning
of Show! or other calls in your program. In this case my code had a bug, but totally unrelated to the
Show function but the problem rises in show function( and I don't remember what it was)
@DSM:
Yes you are correct many times the problem is related to caching but this one not resolved with
refreshing even!!
Thanks guys!Sat, 31 Dec 2011 20:34:27 +0100https://ask.sagemath.org/question/8565/show-function-for-graphs-is-not-working/?answer=13083#post-id-13083