# Revision history [back]

### Show function for graphs is not working!

Hi everyone,

Yesterday I wrote a code the 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 as follows:

a=3 N=6 b=3 G=Graph(multiedges=False); for i in range(N): G.add_vertex(); plot(G); counter=0; #a counter that when reaches to N stops the while and the graph should already be semi-regular pointer=0; #the pointer to the vertex which we try to set its a or b neighbours

# visited.append(False);

while counter<n: ds="list(G.degree_sequence());" if(pointer<n="" 2):="" checker="a" else:="" checker="b;" checked="False;" while(len(g[pointer])<checker):="" checked="True;" v="randint(0,N-1);" while="" (pointer="=v):" v="randint(0,N-1);" print="" 'new="" neighbor:',v;="" if(v<n="" 2):="" checker2="a;" else:="" checker2="b;" temp="len(G[v]);" g.add_edge(pointer,v);="" print="" 'processing="" vertex:',pointer,'with="" neighbours:',g[pointer];="" if="" len(g[v])="=checker2:" if="" len(g[v])="=temp+1:" print="" v,'is="" now="" a="" good="" vertex!'="" counter="counter+1;" if="" len(g[v])="=checker2+1:" if="" len(g[v])="=temp+1:" print="" v,'was="" a="" good="" vertex!="" bot="" no="" more!'="" counter="counter-1;" while(len(g[pointer])&gt;checker):="" checked="True;" v="randint(0,N-1);" while="" (pointer="=v):" rand="randint(0,len(G[pointer])-1);" v="G[pointer][rand];" if(v<n="" 2):="" checker2="a;" else:="" checker2="b;" print="" 'processing="" vertex:',pointer,'with="" degree:',g[pointer];="" print="" 'neighbor:',v;="" if(len(g[v])="=checker2):" print="" v,'was="" a="" good="" vertex!="" bot="" no="" more!'="" counter="counter-1;" if(len(g[v])="=checker2+1):" print="" v,'is="" now="" a="" good="" vertex!'="" counter="counter+1;" g.delete_edge([pointer,v]);="" plot(g);="" if="" checked="=True:" counter="counter+1;" pointer="mod(pointer+1,N);" print="" 'counter:',counter;<="" p="">

### Show function for graphs is not working!

Hi everyone,

Yesterday I wrote a code the 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 as follows:

a=3;


a=3 N=6 b=3 N=6; b=3; G=Graph(multiedges=False); for i in range(N): G.add_vertex(); plot(G); counter=0; #a counter that when reaches to N stops the while and the graph should already be semi-regular pointer=0; #the pointer to the vertex which we try to set its a or b neighbours

# visited.append(False);

neighbours while counter<n: ds="list(G.degree_sequence());" if(pointer<n="" 2):="" checker="a" else:="" checker="b;" checked="False;" while(len(g[pointer])<checker):="" checked="True;" v="randint(0,N-1);" while="" (pointer="=v):" v="randint(0,N-1);" print="" 'new="" neighbor:',v;="" if(v<n="" 2):="" checker2="a;" else:="" checker2="b;" temp="len(G[v]);" g.add_edge(pointer,v);="" print="" 'processing="" vertex:',pointer,'with="" neighbours:',g[pointer];="" if="" len(g[v])="=checker2:" if="" len(g[v])="=temp+1:" print="" v,'is="" now="" a="" good="" vertex!'="" counter="counter+1;" if="" len(g[v])="=checker2+1:" if="" len(g[v])="=temp+1:" print="" v,'was="" a="" good="" vertex!="" bot="" no="" more!'="" counter="counter-1;" while(len(g[pointer])&gt;checker):="" checked="True;" v="randint(0,N-1);" while="" (pointer="=v):" rand="randint(0,len(G[pointer])-1);" v="G[pointer][rand];" if(v<n="" 2):="" checker2="a;" else:="" checker2="b;" print="" 'processing="" vertex:',pointer,'with="" degree:',g[pointer];="" print="" 'neighbor:',v;="" if(len(g[v])="=checker2):" print="" v,'was="" a="" good="" vertex!="" bot="" no="" more!'="" more!';="" counter="counter-1;" if(len(g[v])="=checker2+1):" print="" v,'is="" now="" a="" good="" vertex!'="" counter="counter+1;" g.delete_edge([pointer,v]);="" plot(g);="" if="" checked="=True:" counter="counter+1;" pointer="mod(pointer+1,N);" print="" 'counter:',counter;<="" p="">

### Show function for graphs is not working!

Hi everyone,

Yesterday I wrote a code the 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 as follows:

a=3;


a=3; N=6; b=3; G=Graph(multiedges=False); for i in range(N): G.add_vertex(); plot(G); counter=0; #a counter that when reaches to N stops the while and the graph should already be semi-regular pointer=0; #the pointer to the vertex which we try to set its a or b neighbours while counter<n: ds="list(G.degree_sequence());" if(pointer<n="" 2):="" checker="a" else:="" checker="b;" checked="False;" while(len(g[pointer])<checker):="" checked="True;" v="randint(0,N-1);" while="" (pointer="=v):" v="randint(0,N-1);" print="" 'new="" neighbor:',v;="" if(v<n="" 2):="" checker2="a;" else:="" checker2="b;" temp="len(G[v]);" g.add_edge(pointer,v);="" print="" 'processing="" vertex:',pointer,'with="" neighbours:',g[pointer];="" if="" len(g[v])="=checker2:" if="" len(g[v])="=temp+1:" print="" v,'is="" now="" a="" good="" vertex!'="" counter="counter+1;" if="" len(g[v])="=checker2+1:" if="" len(g[v])="=temp+1:" print="" v,'was="" a="" good="" vertex!="" bot="" no="" more!'="" counter="counter-1;" while(len(g[pointer])&gt;checker):="" checked="True;" v="randint(0,N-1);" while="" (pointer="=v):" rand="randint(0,len(G[pointer])-1);" v="G[pointer][rand];" if(v<n="" 2):="" checker2="a;" else:="" checker2="b;" print="" 'processing="" vertex:',pointer,'with="" degree:',g[pointer];="" print="" 'neighbor:',v;="" if(len(g[v])="=checker2):" print="" v,'was="" a="" good="" vertex!="" bot="" no="" more!';="" counter="counter-1;" if(len(g[v])="=checker2+1):" print="" v,'is="" now="" a="" good="" vertex!'="" counter="counter+1;" g.delete_edge([pointer,v]);="" plot(g);="" if="" checked="=True:" counter="counter+1;" pointer="mod(pointer+1,N);" print="" 'counter:',counter;<="" 'counter:',counter;'<="" p="">

### Show function for graphs is not working!

Hi everyone,

Yesterday I wrote a code the 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 as follows:

a=3;

Blockquote

a=3; N=6; b=3; G=Graph(multiedges=False); for i in range(N): G.add_vertex(); plot(G); counter=0; #a counter that when reaches to N stops the while and the graph should already be semi-regular pointer=0; #the pointer to the vertex which we try to set its a or b neighbours while counter<n: ds="list(G.degree_sequence());" if(pointer<n="" 2):="" checker="a" else:="" checker="b;" checked="False;" while(len(g[pointer])<checker):="" checked="True;" v="randint(0,N-1);" while="" (pointer="=v):" v="randint(0,N-1);" print="" 'new="" neighbor:',v;="" if(v<n="" 2):="" checker2="a;" else:="" checker2="b;" temp="len(G[v]);" g.add_edge(pointer,v);="" print="" 'processing="" vertex:',pointer,'with="" neighbours:',g[pointer];="" if="" len(g[v])="=checker2:" if="" len(g[v])="=temp+1:" print="" v,'is="" now="" a="" good="" vertex!'="" counter="counter+1;" if="" len(g[v])="=checker2+1:" if="" len(g[v])="=temp+1:" print="" v,'was="" a="" good="" vertex!="" bot="" no="" more!'="" counter="counter-1;" while(len(g[pointer])&gt;checker):="" checked="True;" v="randint(0,N-1);" while="" (pointer="=v):" rand="randint(0,len(G[pointer])-1);" v="G[pointer][rand];" if(v<n="" 2):="" checker2="a;" else:="" checker2="b;" print="" 'processing="" vertex:',pointer,'with="" degree:',g[pointer];="" print="" 'neighbor:',v;="" if(len(g[v])="=checker2):" print="" v,'was="" a="" good="" vertex!="" bot="" no="" more!';="" counter="counter-1;" if(len(g[v])="=checker2+1):" print="" v,'is="" now="" a="" good="" vertex!'="" counter="counter+1;" g.delete_edge([pointer,v]);="" plot(g);="" if="" checked="=True:" counter="counter+1;" pointer="mod(pointer+1,N);" print="" 'counter:',counter;'<="" 'counter:',counter;<="" p="">

Blockquote

### Show function for graphs is not working!

Hi everyone,

Yesterday I wrote a code the 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 as follows:at: http://www.4shared.com/file/ZKT9x0W2/Generating_Regular_Graphs.html

Blockquote

a=3; N=6; b=3; G=Graph(multiedges=False); for i in range(N): G.add_vertex(); plot(G); counter=0; #a counter that when reaches to N stops the while and the graph should already be semi-regular pointer=0; #the pointer to the vertex which we try to set its a or b neighbours while counter<n: ds="list(G.degree_sequence());" if(pointer<n="" 2):="" checker="a" else:="" checker="b;" checked="False;" while(len(g[pointer])<checker):="" checked="True;" v="randint(0,N-1);" while="" (pointer="=v):" v="randint(0,N-1);" print="" 'new="" neighbor:',v;="" if(v<n="" 2):="" checker2="a;" else:="" checker2="b;" temp="len(G[v]);" g.add_edge(pointer,v);="" print="" 'processing="" vertex:',pointer,'with="" neighbours:',g[pointer];="" if="" len(g[v])="=checker2:" if="" len(g[v])="=temp+1:" print="" v,'is="" now="" a="" good="" vertex!'="" counter="counter+1;" if="" len(g[v])="=checker2+1:" if="" len(g[v])="=temp+1:" print="" v,'was="" a="" good="" vertex!="" bot="" no="" more!'="" counter="counter-1;" while(len(g[pointer])&gt;checker):="" checked="True;" v="randint(0,N-1);" while="" (pointer="=v):" rand="randint(0,len(G[pointer])-1);" v="G[pointer][rand];" if(v<n="" 2):="" checker2="a;" else:="" checker2="b;" print="" 'processing="" vertex:',pointer,'with="" degree:',g[pointer];="" print="" 'neighbor:',v;="" if(len(g[v])="=checker2):" print="" v,'was="" a="" good="" vertex!="" bot="" no="" more!';="" counter="counter-1;" if(len(g[v])="=checker2+1):" print="" v,'is="" now="" a="" good="" vertex!'="" counter="counter+1;" g.delete_edge([pointer,v]);="" plot(g);="" if="" checked="=True:" counter="counter+1;" pointer="mod(pointer+1,N);" print="" 'counter:',counter;<="" p="">

Blockquote

### Show function for graphs is not working!

Hi everyone,

Yesterday I wrote a code the 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

### 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...
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.2665722668170929, "perplexity": 9933.75310410005}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2021-31/segments/1627046152000.25/warc/CC-MAIN-20210726031942-20210726061942-00264.warc.gz"}