@@ -57,7 +57,7 @@ def JohnsonGraph(n, k):
57
57
True
58
58
"""
59
59
60
- g = Graph (name = "Johnson graph with parameters " + str ( n ) + "," + str ( k ) )
60
+ g = Graph (name = f "Johnson graph with parameters { n } , { k } " )
61
61
from sage .combinat .subset import Set , Subsets
62
62
63
63
S = Set (range (n ))
@@ -113,7 +113,7 @@ def KneserGraph(n, k):
113
113
if k <= 0 or k > n :
114
114
raise ValueError ("Parameter k should be a strictly positive integer inferior to n" )
115
115
116
- g = Graph (name = "Kneser graph with parameters {},{}" . format ( n , k ) )
116
+ g = Graph (name = f "Kneser graph with parameters { n } ,{ k } " )
117
117
118
118
from sage .combinat .subset import Subsets
119
119
S = Subsets (n , k )
@@ -389,7 +389,7 @@ def EgawaGraph(p, s):
389
389
"""
390
390
from sage .graphs .generators .basic import CompleteGraph
391
391
from itertools import product , chain , repeat
392
- g = Graph (name = "Egawa Graph with parameters " + str ( p ) + "," + str ( s ) , multiedges = False )
392
+ g = Graph (name = f "Egawa Graph with parameters { p } , { s } " , multiedges = False )
393
393
X = CompleteGraph (4 )
394
394
Y = Graph ('O?Wse@UgqqT_LUebWkbT_' )
395
395
g .add_vertices (product (* chain (repeat (Y , p ), repeat (X , s ))))
@@ -477,7 +477,7 @@ def HammingGraph(n, q, X=None):
477
477
X = list (range (q ))
478
478
if q != len (X ):
479
479
raise ValueError ("q must be the cardinality of X" )
480
- g = Graph (name = "Hamming Graph with parameters " + str ( n ) + "," + str ( q ) , multiedges = False )
480
+ g = Graph (name = f "Hamming Graph with parameters { n } , { q } " , multiedges = False )
481
481
g .add_vertices (product (* repeat (X , n )))
482
482
for v in g :
483
483
for i in range (n ):
@@ -1161,7 +1161,7 @@ def CirculantGraph(n, adjacency):
1161
1161
if not isinstance (adjacency , list ):
1162
1162
adjacency = [adjacency ]
1163
1163
1164
- G = Graph (n , name = "Circulant graph (" + str ( adjacency ) + " )" )
1164
+ G = Graph (n , name = f "Circulant graph ({ adjacency } )" )
1165
1165
G ._circle_embedding (list (range (n )))
1166
1166
1167
1167
for v in G :
@@ -1275,7 +1275,7 @@ def CubeGraph(n, embedding=1):
1275
1275
p , pn = pn , {}
1276
1276
1277
1277
# construct the graph
1278
- G = Graph (d , format = 'dict_of_lists' , pos = p , name = "%d -Cube" % n )
1278
+ G = Graph (d , format = 'dict_of_lists' , pos = p , name = f" { n } -Cube" )
1279
1279
1280
1280
else :
1281
1281
# construct recursively the adjacency dict
@@ -1296,7 +1296,7 @@ def CubeGraph(n, embedding=1):
1296
1296
d , dn = dn , {}
1297
1297
1298
1298
# construct the graph
1299
- G = Graph (d , name = "%d -Cube" % n , format = 'dict_of_lists' )
1299
+ G = Graph (d , name = f" { n } -Cube" , format = 'dict_of_lists' )
1300
1300
1301
1301
if embedding == 2 :
1302
1302
# Orthogonal projection
@@ -1398,7 +1398,7 @@ def DorogovtsevGoltsevMendesGraph(n):
1398
1398
"""
1399
1399
import networkx
1400
1400
return Graph (networkx .dorogovtsev_goltsev_mendes_graph (n ),
1401
- name = "Dorogovtsev-Goltsev-Mendes Graph, %d -th generation" % n )
1401
+ name = f "Dorogovtsev-Goltsev-Mendes Graph, { n } -th generation" )
1402
1402
1403
1403
1404
1404
def FoldedCubeGraph (n ):
@@ -1637,7 +1637,7 @@ def FibonacciTree(n):
1637
1637
1638
1638
- Harald Schilly and Yann Laigle-Chapuy (2010-03-25)
1639
1639
"""
1640
- T = Graph (name = "Fibonacci-Tree-%d" % n )
1640
+ T = Graph (name = f "Fibonacci-Tree-{ n } " )
1641
1641
if n == 1 :
1642
1642
T .add_vertex (0 )
1643
1643
if n < 2 :
@@ -1719,7 +1719,7 @@ def GeneralizedPetersenGraph(n, k):
1719
1719
raise ValueError ("n must be larger than 2" )
1720
1720
if k < 1 or k > (n - 1 ) // 2 :
1721
1721
raise ValueError ("k must be in 1<= k <=floor((n-1)/2)" )
1722
- G = Graph (2 * n , name = "Generalized Petersen graph (n='+str(n)+' ,k=" + str ( k ) + " )" )
1722
+ G = Graph (2 * n , name = f "Generalized Petersen graph (n={ n } ,k={ k } )" )
1723
1723
for i in range (n ):
1724
1724
G .add_edge (i , (i + 1 ) % n )
1725
1725
G .add_edge (i , i + n )
@@ -1804,7 +1804,7 @@ def IGraph(n, j, k):
1804
1804
if k < 1 or k > (n - 1 ) // 2 :
1805
1805
raise ValueError ("k must be in 1 <= k <= floor((n - 1) / 2)" )
1806
1806
1807
- G = Graph (2 * n , name = "I-graph (n={}, j={}, k={})" . format ( n , j , k ) )
1807
+ G = Graph (2 * n , name = f "I-graph (n={ n } , j={ j } , k={ k } )" )
1808
1808
for i in range (n ):
1809
1809
G .add_edge (i , (i + j ) % n )
1810
1810
G .add_edge (i , i + n )
@@ -1870,7 +1870,7 @@ def DoubleGeneralizedPetersenGraph(n, k):
1870
1870
if k < 1 or k > (n - 1 ) // 2 :
1871
1871
raise ValueError ("k must be in 1 <= k <= floor((n - 1) / 2)" )
1872
1872
1873
- G = Graph (4 * n , name = "Double generalized Petersen graph (n={}, k={})" . format ( n , k ) )
1873
+ G = Graph (4 * n , name = f "Double generalized Petersen graph (n={ n } , k={ k } )" )
1874
1874
for i in range (n ):
1875
1875
G .add_edge (i , (i + 1 ) % n )
1876
1876
G .add_edge (i + 3 * n , (i + 1 ) % n + 3 * n )
@@ -1963,7 +1963,7 @@ def RoseWindowGraph(n, a, r):
1963
1963
if r == n / 2 :
1964
1964
raise ValueError ("r must be different than n / 2" )
1965
1965
1966
- G = Graph (2 * n , name = "rose window graph (n={}, a={}, r={})". format ( n , a , r ) )
1966
+ G = Graph (2 * n , name = f"Rose window graph (n={ n } , a={ a } , r={ r } )" )
1967
1967
for i in range (n ):
1968
1968
G .add_edge (i , (i + 1 ) % n )
1969
1969
G .add_edge (i , i + n )
@@ -2071,7 +2071,7 @@ def TabacjnGraph(n, a, b, r):
2071
2071
if r == n / 2 :
2072
2072
raise ValueError ("r must be different than n / 2" )
2073
2073
2074
- G = Graph (2 * n , name = "Tabačjn graph (n={}, a={}, b={}, r={})" . format ( n , a , b , r ) )
2074
+ G = Graph (2 * n , name = f "Tabačjn graph (n={ n } , a={ a } , b={ b } , r={ r } )" )
2075
2075
for i in range (n ):
2076
2076
G .add_edge (i , (i + 1 ) % n )
2077
2077
G .add_edge (i , i + n )
@@ -2210,7 +2210,7 @@ def HyperStarGraph(n, k):
2210
2210
c [i ] = one
2211
2211
adj [u ] = L
2212
2212
2213
- return Graph (adj , format = 'dict_of_lists' , name = "HS(%d,%d)" % ( n , k ) )
2213
+ return Graph (adj , format = 'dict_of_lists' , name = f "HS({ n } , { k } )" )
2214
2214
2215
2215
2216
2216
def LCFGraph (n , shift_list , repeats ):
@@ -2450,7 +2450,7 @@ def NKStarGraph(n, k):
2450
2450
tmp_dict [vert ] = None
2451
2451
v [0 ] = tmp_bit
2452
2452
d ["" .join (v )] = tmp_dict
2453
- return Graph (d , name = "(%d,%d )-star" % ( n , k ) )
2453
+ return Graph (d , name = f"( { n } , { k } )-star" )
2454
2454
2455
2455
2456
2456
def NStarGraph (n ):
@@ -2498,7 +2498,7 @@ def NStarGraph(n):
2498
2498
# swap back
2499
2499
v [0 ], v [i ] = v [i ], v [0 ]
2500
2500
d ["" .join (v )] = tmp_dict
2501
- return Graph (d , name = "%d -star" % n )
2501
+ return Graph (d , name = f" { n } -star" )
2502
2502
2503
2503
2504
2504
def OddGraph (n ):
@@ -2579,7 +2579,7 @@ def PaleyGraph(q):
2579
2579
if not mod (q , 4 ) == 1 :
2580
2580
raise ValueError ("parameter q must be congruent to 1 mod 4" )
2581
2581
g = Graph ([FiniteField (q , 'a' ), lambda i , j : (i - j ).is_square ()],
2582
- loops = False , name = "Paley graph with parameter {}" . format ( q ) )
2582
+ loops = False , name = f "Paley graph with parameter { q } " )
2583
2583
return g
2584
2584
2585
2585
@@ -4400,7 +4400,7 @@ def CubeConnectedCycle(d):
4400
4400
if d < 1 :
4401
4401
raise ValueError ('the dimension d must be greater than 0' )
4402
4402
4403
- G = Graph (name = "Cube-Connected Cycle of dimension {}" . format ( d ) )
4403
+ G = Graph (name = f "Cube-Connected Cycle of dimension { d } " )
4404
4404
4405
4405
if d == 1 :
4406
4406
G .allow_loops (True )
0 commit comments