qeh6‰h7Kh!h#h8h%h&‰h9‰ub(hoqf}qg(hCUE.TorsionSubgroup()qhhEU!qihGhhH‰hI‰hJU hKMhL‰hMUcos.chdir("/Users/was/talks/2007-01-05-msr/sage_notebook/worksheets/_/cells/14")
E.TorsionSubgroup()qjU_word_being_completedqkUE.TorsionSuqlhOU#sage_notebook/worksheets/_/cells/14qmhQU
Abelian Group of order 1
qnhS‰hTh#hUKhVh%hW‰hX‰ub(hoqo}qp(hCUa = magma(-5/6)qqhEU!qrhGhhH‰hI‰hJU hKMhL‰hMU_os.chdir("/Users/was/talks/2007-01-05-msr/sage_notebook/worksheets/_/cells/16")
a = magma(-5/6)qshOU#sage_notebook/worksheets/_/cells/16qthQU
quhS‰hTh#hUKhVh%hW‰hX‰ub(hoqv}qw(hCUahEU!qxhGhhH‰hI‰hJU hKMhL‰hMUQos.chdir("/Users/was/talks/2007-01-05-msr/sage_notebook/worksheets/_/cells/17")
aqyhOU#sage_notebook/worksheets/_/cells/17qzhQU
-5/6
q{hS‰hTh#hUKhVh%hW‰hX‰ub(hoq|}q}(hCU b = gp(a)q~hEU!qhGhhH‰hI‰hJU hKMhL‰hMUYos.chdir("/Users/was/talks/2007-01-05-msr/sage_notebook/worksheets/_/cells/18")
b = gp(a)q€hOU#sage_notebook/worksheets/_/cells/18qhQU
q‚hS‰hTh#hUKhVh%hW‰hX‰ub(hoqƒ}q„(hCUbhEU!q…hGhhH‰hI‰hJU hKMhL‰hMUQos.chdir("/Users/was/talks/2007-01-05-msr/sage_notebook/worksheets/_/cells/19")
bq†hOU#sage_notebook/worksheets/_/cells/19q‡hQU
-5/6
qˆhS‰hTh#hUKhVh%hW‰hX‰ub(hoq‰}qŠ(hCU
s = str(a)q‹hEU!qŒhGhhH‰hI‰hJU hKMhL‰hMUZos.chdir("/Users/was/talks/2007-01-05-msr/sage_notebook/worksheets/_/cells/20")
s = str(a)qhOU#sage_notebook/worksheets/_/cells/20qŽhQU
qhS‰hTh#hUKhVh%hW‰hX‰ub(hoq}q‘(hCUshEU!q’hGhhH‰hI‰hJU hKMhL‰hMUQos.chdir("/Users/was/talks/2007-01-05-msr/sage_notebook/worksheets/_/cells/21")
sq“hOU#sage_notebook/worksheets/_/cells/21q”hQU
'-5/6'
q•hS‰hTh#hUKhVh%hW‰hX‰ub(hoq–}q—(hCUsage_eval(s)q˜hEU!q™hGhhH‰hI‰hJU hKMhL‰hMU\os.chdir("/Users/was/talks/2007-01-05-msr/sage_notebook/worksheets/_/cells/22")
sage_eval(s)qšhOU#sage_notebook/worksheets/_/cells/22q›hQU
-5/6
qœhS‰hTh#hUKhVh%hW‰hX‰ub(hoq}qž(hCUmagma.eval('2^10')qŸhEU!q hGhhH‰hI‰hJU hKMhL‰hMUbos.chdir("/Users/was/talks/2007-01-05-msr/sage_notebook/worksheets/_/cells/15")
magma.eval('2^10')q¡hOU#sage_notebook/worksheets/_/cells/15q¢hQU
'1024'
q£hS‰hTh#hUKhVh%hW‰hX‰ub(hoq¤}q¥(h*UE.name()q¦hU!q§h-hh.‰h‰h/U h0Mh‰hUaos.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/_/cells/5")
E.name()q¨h2U"sage_notebook/worksheets/_/cells/5q©h4U
'_sage_[7]'
qªh6‰h7Kh!h")Rq«h8Uwrapq¬h&‰h9‰ub(hoq}q®(h*UE.Rank()q¯hU!q°h-hh.‰h‰h/U h0Mh‰hUaos.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/_/cells/6")
E.Rank()q±h2U"sage_notebook/worksheets/_/cells/6q²h4U
1
q³h6‰h7Kh!h«h8h¬h&‰h9‰ub(hoq´}qµ(h*Ua = maple('2007')q¶hU!q·h-hh.‰h‰h/U h0Mh‰hUjos.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/_/cells/7")
a = maple('2007')q¸h2U"sage_notebook/worksheets/_/cells/7q¹h4U
qºh6‰h7Kh!h«h8h¬h&‰h9‰ub(hoq»}q¼(h*UahU!q½h-hh.‰h‰h/U h0Mh‰hUZos.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/_/cells/8")
aq¾h2U"sage_notebook/worksheets/_/cells/8q¿h4U
2007
qÀh6‰h7Kh!h«h8h¬h&‰h9‰ub(hoqÁ}qÂ(h*Ua.ifactor()qÃhU!qÄh-hh.‰h‰h/U h0M h‰hUdos.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/_/cells/9")
a.ifactor()qÅh2U"sage_notebook/worksheets/_/cells/9qÆh4U
``(3)^2*``(223)
qÇh6‰h7Kh!h«h8h¬h&‰h9‰ub(hoqÈ}qÉ(h*Ua.name()qÊhU!qËh-hh.‰h‰h/U h‰h0M
U_word_being_completedqÌUa.ifacqÍhUbos.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/_/cells/10")
a.name()qÎh2U#sage_notebook/worksheets/_/cells/10qÏh4U
'sage1'
qÐh6‰h7Kh!h«h8h¬h&‰h9‰ub(hoqÑ}qÒ(h*Ufor i in range(5):
print iqÓhU!qÔh-hh.‰h‰h/U h0Mh‰hUxos.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/_/cells/11")
for i in range(5):
print iqÕh2U#sage_notebook/worksheets/_/cells/11qÖh4U
0
1
2
3
4
q×h6‰h7Kh!h«h8h¬h&‰h9‰ub(hoqØ}qÙ(h*U h-hh.‰h/U h0Mh2U#sage_notebook/worksheets/_/cells/12qÚh4U h6‰h7K h8h¬h9‰ubeU_Worksheet__synchroqÛK$U_Worksheet__comp_is_runningq܉U_Worksheet__dirqÝUsage_notebook/worksheets/_qÞU_Worksheet__variablesqß]qà(U$E-sage.interfaces.magma.MagmaElementqáU$a-sage.interfaces.magma.MagmaElementqâUb-sage.interfaces.gp.GpElementqãUs-strqäeU_Worksheet__attachedqå}qæU_Worksheet__queueqç]qèU_Worksheet__next_idqéMU_Worksheet__sageqêh#U_Worksheet__passcryptqëˆU_Worksheet__nameqìU U_Worksheet__saltqíU1165187731.576083qîU_Worksheet__notebookqïhU_Worksheet__idqðKU_Worksheet__next_block_idqñKU_Worksheet__systemqòNU_Worksheet__passcodeqóU
11G3BJNEUV/PkqôubUqsieveqõ(hoqö}q÷(U_Worksheet__filenameqøUqsieveqùU_Worksheet__cellsqú]qû((hoqü}qý(U _Cell__inqþU/n = next_prime(10^32)*next_prime(10^33)
print nqÿU_Cell__introspect_htmlr U!r U_Cell__worksheetr höU_Cell__completionsr ‰U_Cell__introspectr ‰U_Cell__out_htmlr U U
_Cell__outr UE
100000000000000000000000000000055100000000000000000000000000002989
r U _Cell__idr M `U_Cell__is_htmlr ‰U_before_preparser
Uƒos.chdir("/Users/was/talks/2007-01-05-msr/sage_notebook/worksheets/qsieve/cells/0")
n = next_prime(10^32)*next_prime(10^33)
print nr U
_Cell__dirr U'sage_notebook/worksheets/qsieve/cells/0r
U_word_being_completedr Uqsir Uhas_new_outputr ‰U_Cell__versionr KU_Cell__sager h«U_Cell__typer Uwrapr U_Cell__timer ‰U_Cell__interruptedr ‰ub(hor }r (hþUtime factor(n) r j U!r j höj ‰j ‰j U j M`j ‰j
Uˆos.chdir("/Users/was/talks/2007-01-05-msr/sage_notebook/worksheets/qsieve/cells/1")
__SAGE_t__=cputime()
__SAGE_w__=walltime()
factor(n)r j U'sage_notebook/worksheets/qsieve/cells/1r j Up
100000000000000000000000000000049 * 1000000000000000000000000000000061
CPU time: 64.23 s, Wall time: 87.90 s
r j ‰j Kj h«j j j ˆj ‰ub(hor }r (hþU+F, t = qsieve(n, time=True)
print F
print tr j U!r! j höj ‰j ‰j U j Ux
[100000000000000000000000000000049, 1000000000000000000000000000000061]
80.95 real 45.56 user 0.49 sys
r" j M`j ‰j
Uos.chdir("/Users/was/talks/2007-01-05-msr/sage_notebook/worksheets/qsieve/cells/2")
F, t = qsieve(n, time=True)
print F
print tr# j U'sage_notebook/worksheets/qsieve/cells/2r$ j Uqsir% j ‰j Kj h«j j j ‰j ‰ub(hor& }r' (hþU%q = qsieve(n, time=True, block=False)r( j U!r) j höj ‰j ‰j U j M`j ‰j
Uyos.chdir("/Users/was/talks/2007-01-05-msr/sage_notebook/worksheets/qsieve/cells/3")
q = qsieve(n, time=True, block=False)r* j U'sage_notebook/worksheets/qsieve/cells/3r+ j U
r, j ‰j Kj h«j j j ‰j ‰ub(hor- }r. (hþUqj U!r/ j höj ‰j ‰j U j U
([], '')
r0 j M`j ‰j
UUos.chdir("/Users/was/talks/2007-01-05-msr/sage_notebook/worksheets/qsieve/cells/4")
qr1 j U'sage_notebook/worksheets/qsieve/cells/4r2 j Uq.cpur3 j ‰j Kj h«j j j ‰j ‰ub(hor4 }r5 (hþU2+2r6 j U!r7 j höj ‰j ‰j U j M`j ‰j
UWos.chdir("/Users/was/talks/2007-01-05-msr/sage_notebook/worksheets/qsieve/cells/5")
2+2r8 j U'sage_notebook/worksheets/qsieve/cells/5r9 j U
4
r: j ‰j Kj h«j j j ‰j ‰ub(hor; }r< (hþU
print q.log()r= j U!r> j höj ‰j ‰j U j T”
Input number to factor [ >=40 decimal digits]: 100000000000000000000000000000055100000000000000000000000000002989
100 relations, 9 partials.
1260 curves.
200 relations, 15 partials.
2520 curves.
300 relations, 25 partials.
400 relations, 38 partials.
3780 curves.
500 relations, 46 partials.
600 relations, 55 partials.
5040 curves.
700 relations, 61 partials.
6300 curves.
800 relations, 70 partials.
900 relations, 81 partials.
7560 curves.
1000 relations, 90 partials.
8820 curves.
1100 relations, 96 partials.
1200 relations, 106 partials.
10080 curves.
1300 relations, 109 partials.
11340 curves.
1400 relations, 121 partials.
1500 relations, 135 partials.
12600 curves.
1600 relations, 151 partials.
13860 curves.
1700 relations, 162 partials.
15120 curves.
1800 relations, 172 partials.
1900 relations, 181 partials.
16380 curves.
2000 relations, 194 partials.
17640 curves.
2100 relations, 203 partials.
2200 relations, 213 partials.
18900 curves.
2300 relations, 225 partials.
20160 curves.
2400 relations, 237 partials.
2500 relations, 247 partials.
21420 curves.
2600 relations, 255 partials.
22680 curves.
2700 relations, 273 partials.
2800 relations, 280 partials.
23940 curves.
2900 relations, 298 partials.
25200 curves.
3000 relations, 307 partials.
3100 relations, 318 partials.
26460 curves.
3200 relations, 324 partials.
27720 curves.
3300 relations, 334 partials.
3400 relations, 340 partials.
28980 curves.
3500 relations, 350 partials.
3600 relations, 363 partials.
30240 curves.
3700 relations, 374 partials.
31500 curves.
3800 relations, 389 partials.
32760 curves.
3900 relations, 398 partials.
4000 relations, 415 partials.
34020 curves.
4100 relations, 429 partials.
4200 relations, 438 partials.
35280 curves.
4300 relations, 453 partials.
36540 curves.
4400 relations, 461 partials.
4500 relations, 473 partials.
37800 curves.
4600 relations, 486 partials.
39060 curves.
4700 relations, 498 partials.
40320 curves.
4800 relations, 507 partials.
4900 relations, 526 partials.
41580 curves.
5000 relations, 540 partials.
42840 curves.
5100 relations, 555 partials.
5200 relations, 565 partials.
44100 curves.
5300 relations, 574 partials.
45360 curves.
5400 relations, 587 partials.
5500 relations, 597 partials.
46620 curves.
5600 relations, 604 partials.
47880 curves.
5700 relations, 614 partials.
5800 relations, 623 partials.
49140 curves.
5900 relations, 634 partials.
50400 curves.
6000 relations, 645 partials.
r? j M`j ‰j
Uaos.chdir("/Users/was/talks/2007-01-05-msr/sage_notebook/worksheets/qsieve/cells/6")
print q.log()r@ j U'sage_notebook/worksheets/qsieve/cells/6rA j Uq.rB j ‰j Kj h«j j j ‰j ‰ub(horC }rD (hþUq.quit()rE j U!rF j höj ‰j ‰j U j M`j ‰j
U\os.chdir("/Users/was/talks/2007-01-05-msr/sage_notebook/worksheets/qsieve/cells/7")
q.quit()rG j U'sage_notebook/worksheets/qsieve/cells/7rH j U
rI j ‰j Kj h«j j j ‰j ‰ub(horJ }rK (hþU j höj ‰j U j M`j U'sage_notebook/worksheets/qsieve/cells/8rL j U j ‰j K j j j ‰ubeU_Worksheet__synchrorM K1U_Worksheet__namerN UqsieverO U_Worksheet__attachedrP }rQ U_Worksheet__saltrR U1168019690.935546rS U_Worksheet__dirrT Usage_notebook/worksheets/qsieverU U_Worksheet__queuerV ]rW U_Worksheet__next_idrX M `U_Worksheet__passcryptrY ˆU_Worksheet__comp_is_runningrZ ‰U_Worksheet__passcoder[ U
11G3BJNEUV/Pkr\ U_Worksheet__notebookr] hU_Worksheet__idr^ KU_Worksheet__next_block_idr_ KU_Worksheet__systemr` NubUboothbyra (horb }rc (U_Worksheet__filenamerd Uboothbyre U_Worksheet__cellsrf ]rg ((horh }ri (hCU(A = MatrixSpace(ZZ,100).random_element()rj hEU!rk hGjb hH‰hI‰hJU hKK hL‰hMU}os.chdir("/Users/was/talks/2007-01-05-msr/sage_notebook/worksheets/boothby/cells/0")
A = MatrixSpace(ZZ,100).random_element()rl hOU(sage_notebook/worksheets/boothby/cells/0rm hQU
rn hS‰hTh")Rro hUKhVh%hW‰hX‰ub(horp }rq (hCUA.characteristic_polynomial()rr hET™ rs hGjb hH‰hI‰hJU hKKhL‰hMUros.chdir("/Users/was/talks/2007-01-05-msr/sage_notebook/worksheets/boothby/cells/1")
A.characteristic_polynomial()rt hkUA.charu hOU(sage_notebook/worksheets/boothby/cells/1rv hQU hS‰hTNhUKhVh%hW‰hXˆub(horw }rx (hCU hGjb hH‰hJU hKKhOU(sage_notebook/worksheets/boothby/cells/2ry hQU hS‰hUK hVh%hX‰ubeU_Worksheet__synchrorz KU_Worksheet__comp_is_runningr{ ‰U_Worksheet__dirr| U sage_notebook/worksheets/boothbyr} U_Worksheet__attachedr~ }r U_Worksheet__passcoder€ U
11G3BJNEUV/Pkr U_Worksheet__queuer‚ ]rƒ U_Worksheet__next_idr„ Khß]r… U7A-sage.matrix.matrix_integer_dense.Matrix_integer_denser† aU_Worksheet__passcryptr‡ ˆU_Worksheet__namerˆ Uboothbyr‰ U_Worksheet__saltrŠ U1168036645.916354r‹ U_Worksheet__notebookrŒ hU_Worksheet__next_block_idr KU_Worksheet__idrŽ K hêjo U_Worksheet__systemr NubUgraphr (hor‘ }r’ (h Ugraphr“ h
]r” ((hor• }r– (U _Cell__inr— U*time b = bernoulli(10000, algorithm='gap')r˜ U_Cell__introspect_htmlr™ U!rš U_Cell__worksheetr› j‘ U_Cell__completionsrœ ‰U_Cell__introspectr ‰U_Cell__out_htmlrž U U _Cell__idrŸ M0U_Cell__is_htmlr ‰U_before_preparser¡ U®os.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/graph/cells/14")
__SAGE_t__=cputime()
__SAGE_w__=walltime()
b = bernoulli(10000, algorithm='gap')r¢ U
_Cell__dirr£ U'sage_notebook/worksheets/graph/cells/14r¤ U_word_being_completedr¥ Ubernr¦ Uhas_new_outputr§ ‰U_Cell__versionr¨ KU_Cell__sager© NU_Cell__interruptedrª ˆU_Cell__typer« Uwrapr¬ U_Cell__timer ˆU
_Cell__outr® U ub(hor¯ }r° (j— U+time b = bernoulli(10000, algorithm='pari')r± j™ U!r² j› j‘ jœ ‰j ‰jž U jŸ M0j ‰j¡ U¯os.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/graph/cells/15")
__SAGE_t__=cputime()
__SAGE_w__=walltime()
b = bernoulli(10000, algorithm='pari')r³ j£ U'sage_notebook/worksheets/graph/cells/15r´ j® U'
CPU time: 0.24 s, Wall time: 0.26 s
rµ j§ ‰j¨ Kj© h«j« j¬ j ˆjª ‰ub(hor¶ }r· (j— UE = EllipticCurve('389a')r¸ j™ U!r¹ j› j‘ jœ ‰j ‰jž U jŸ M
0j ‰j¡ Uwos.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/graph/cells/10")
E = EllipticCurve('389a')rº j£ U'sage_notebook/worksheets/graph/cells/10r» j¥ UEllr¼ j§ ‰j¨ Kj© h«jª ‰j« j¬ j ‰j® U
r½ ub(hor¾ }r¿ (j— UL = E.Lseries_zeros(5)rÀ j™ U!rÁ j› j‘ jœ ‰j ‰jž U jŸ M0j ‰j¡ Utos.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/graph/cells/11")
L = E.Lseries_zeros(5)r j£ U'sage_notebook/worksheets/graph/cells/11rà j¥ U
E.Lseries_zerrÄ j§ ‰j¨ Kj© h«jª ‰j« j¬ j ‰j® U
rÅ ub(horÆ }rÇ (j— ULj™ U!rÈ j› j‘ jœ ‰j ‰jž U jŸ M0j ‰j¡ U_os.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/graph/cells/12")
LrÉ j£ U'sage_notebook/worksheets/graph/cells/12rÊ j® UA
[0.000000000, 0.000000000, 2.87609907, 4.41689608, 5.79340263]
rË j§ ‰j¨ Kj© h«j« j¬ j ‰jª ‰ub(horÌ }rÍ (hUg = graphs.PetersenGraph()rÎ U_Cell__introspect_htmlrÏ U!rÐ hj‘ h‰U_Cell__introspectrÑ ‰hU hM 0U_Cell__is_htmlrÒ ‰U_before_preparserÓ Uwos.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/graph/cells/0")
g = graphs.PetersenGraph()rÔ hU&sage_notebook/worksheets/graph/cells/0rÕ U_word_being_completedrÖ U
graphs.Petr× h‰h KU_Cell__sagerØ h«h'‰h$UwraprÙ U_Cell__timerÚ ‰hU
rÛ ub(horÜ }rÝ (hUshow(g)rÞ jÏ U!rß hj‘ h‰jÑ ‰hU>
rà hM0jÒ ‰jÓ Udos.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/graph/cells/1")
show(g)rá hU&sage_notebook/worksheets/graph/cells/1râ hU
rã h‰h KjØ h«h$jÙ jÚ ‰h'‰ub(horä }rå (hU(g = graphs.CompleteBipartiteGraph(5,100)ræ hU!rç hj‘ h‰h‰hU h‰hM0hÌUgraphs.CompleteBirè hU…os.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/graph/cells/2")
g = graphs.CompleteBipartiteGraph(5,100)ré hU&sage_notebook/worksheets/graph/cells/2rê hU
rë h‰h Kh!h«h$j¬ h&‰h'‰ub(horì }rí (h*Ugraphs.CompleteBipartiteGraphrî hT? File: /Volumes/HOME/s/local/lib/python2.5/site-packages/sage/graphs/graph_database.py
Source Code (starting at line 566):
def CompleteBipartiteGraph(self, n1, n2):
"""
Returns a Complete Bipartite Graph sized n1+n2, with each of the
nodes [0,(n1-1)] connected to each of the nodes [n1,(n2-1)] and
vice versa.
A Complete Bipartite Graph is a graph with its vertices partitioned
into two groups, V1 and V2. Each v in V1 is connected to every v
in V2, and vice versa.
PLOTTING:
Upon construction, the position dictionary is filled to override
the spring-layout algorithm. By convention, each complete bipartite
graph will be displayed with the first n1 nodes on the top row (at
y=1) from left to right. The remaining n2 nodes appear at y=0,
also from left to right. The shorter row (partition with fewer
nodes) is stretched to the same length as the longer row, unless
the shorter row has 1 node; in which case it is centered. The x
values in the plot are in domain [0,max{n1,n2}].
In the Complete Bipartite graph, there is a visual difference in
using the spring-layout algorithm vs. the position dictionary used
in this constructor. The position dictionary flattens the graph
and separates the partitioned nodes, making it clear which nodes
an edge is connected to. The Complete Bipartite graph plotted with
the spring-layout algorithm tends to center the nodes in n1 (see
spring_med in examples below), thus overlapping its nodes and edges,
making it typically hard to decipher.
Filling the position dictionary in advance adds O(n) to the
constructor. Feel free to race the constructors below in the
examples section. The much larger difference is the time added by
the spring-layout algorithm when plotting. (Also shown in the
example below). The spring model is typically described as O(n^3),
as appears to be the case in the NetworkX source code.
EXAMPLES:
# The following examples require NetworkX (to use default)
sage: import networkx as NX
# Compare the constructors (results will vary)
sage.: time n = NX.complete_bipartite_graph(389,157); spring_big = Graph(n)
# CPU time: 9.28 s, Wall time: 11.02 s
sage.: time posdict_big = graphs.CompleteBipartiteGraph(389,157)
# CPU time: 10.72 s, Wall time: 13.84 s
# Compare the plotting speeds (results will vary)
sage: n = NX.complete_bipartite_graph(11,17)
sage: spring_med = Graph(n)
sage: posdict_med = graphs.CompleteBipartiteGraph(11,17)
# Notice here how the spring-layout tends to center the nodes of n1
sage.: time spring_med.show()
# CPU time: 3.84 s, Wall time: 4.49 s
sage.: time posdict_med.show()
# CPU time: 0.96 s, Wall time: 1.14 s
# View many Complete Bipartite graphs with a SAGE Graphics Array
# With this constructor (i.e., the position dictionary filled)
sage: g = []
sage: j = []
sage: for i in range(9):
... k = graphs.CompleteBipartiteGraph(i+1,4)
... g.append(k)
...
sage: for i in range(3):
... n = []
... for m in range(3):
... n.append(g[3*i + m].plot(node_size=50, with_labels=False))
... j.append(n)
...
sage: G = sage.plot.plot.GraphicsArray(j)
sage.: G.show()
# Compared to plotting with the spring-layout algorithm
sage: g = []
sage: j = []
sage: for i in range(9):
... spr = NX.complete_bipartite_graph(i+1,4)
... k = Graph(spr)
... g.append(k)
...
sage: for i in range(3):
... n = []
... for m in range(3):
... n.append(g[3*i + m].plot(node_size=50, with_labels=False))
... j.append(n)
...
sage: G = sage.plot.plot.GraphicsArray(j)
sage.: G.show()
"""
pos_dict = {}
c1 = 1 # scaling factor for top row
c2 = 1 # scaling factor for bottom row
c3 = 0 # pad to center if top row has 1 node
c4 = 0 # pad to center if bottom row has 1 node
if n1 > n2:
if n2 == 1:
c4 = (n1-1)/2
else:
c2 = ((n1-1)/(n2-1))
elif n2 > n1:
if n1 == 1:
c3 = (n2-1)/2
else:
c1 = ((n2-1)/(n1-1))
for i in range(n1):
x = c1*i + c3
y = 1
pos_dict[i] = [x,y]
for i in range(n1+n2)[n1:]:
x = c2*(i-n1) + c4
y = 0
pos_dict[i] = [x,y]
G = NX.complete_bipartite_graph(n1,n2)
return graph.Graph(G, pos=pos_dict, name="Complete bipartite graph on %d vertices"%(n1+n2))rï h-j‘ h.‰h]rð (Ugraphs.CompleteBipartiteGraph??rñ U eh/U>
rò h‰h0M0hÌUgraphs.CompleteBiró hU|os.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/graph/cells/3")
graphs.CompleteBipartiteGraph??rô h2U&sage_notebook/worksheets/graph/cells/3rõ h4U
rö h6‰h7Kh!h«h8h¬h&‰h9‰ub(hor÷ }rø (j— Ugj™ U!rù j› j‘ jœ ‰j ‰jž U jŸ M0j ‰j¡ U^os.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/graph/cells/5")
grú j£ U&sage_notebook/worksheets/graph/cells/5rû j® UK
Complete bipartite graph on 105 vertices: a simple graph on 105 vertices
rü j§ ‰j¨ Kj© h«j« j¬ j ‰jª ‰ub(horý }rþ (h*Ug.save('mygraph')rÿ j™ U!r h-j‘ h.‰j ‰h/U h0M0j ‰j¡ Unos.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/graph/cells/4")
g.save('mygraph')r h2U&sage_notebook/worksheets/graph/cells/4r h4U
r h6‰h7Kj© h«h8j¬ j ‰h9‰ub(hor }r (j— U5P = plot(sin, 0, 10, rgbcolor=(0,0.5,0), thickness=5)r j™ U!r j› j‘ jœ ‰j ‰jž U jŸ M0j ‰j¡ U’os.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/graph/cells/6")
P = plot(sin, 0, 10, rgbcolor=(0,0.5,0), thickness=5)r j£ U&sage_notebook/worksheets/graph/cells/6r j® U
r
j§ ‰j¨ Kj© h«j« j¬ j ‰jª ‰ub(hor }r (j— UPj™ U!r
j› j‘ jœ ‰j ‰jž U jŸ M0j ‰j¡ U^os.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/graph/cells/7")
Pr j£ U&sage_notebook/worksheets/graph/cells/7r j® U5
Graphics object consisting of 1 graphics primitive
r j§ ‰j¨ Kj© h«j« j¬ j ‰jª ‰ub(hor }r (j— UP.show()r j™ U!r j› j‘ jœ ‰j ‰jž U>
r jŸ M0j ‰j¡ Ueos.chdir("/Volumes/HOME/talks/2006-12-waterloo/sage/sage_notebook/worksheets/graph/cells/8")
P.show()r j£ U&sage_notebook/worksheets/graph/cells/8r j® U
r j§ ‰j¨ Kj© h«j« j¬ j ‰jª ‰ub(hor }r (j— U j› j‘ jœ ‰jž U jŸ M 0j£ U&sage_notebook/worksheets/graph/cells/9r j® U j§ ‰j¨ K j« j¬ jª ‰ubeU_Worksheet__synchror K