@@ -1250,28 +1250,17 @@ cpdef tuple find_hamiltonian(G, long max_iter=100000, long reset_bound=30000,
1250
1250
1251
1251
The method can also be used for directed graphs::
1252
1252
1253
- sage: G = DiGraph( )
1254
- sage: G. add_path( 'abcd')
1255
- sage: G. add_path( 'xyd')
1253
+ sage: G = DiGraph( [(0, 1), (1, 2), (2, 3) ])
1256
1254
sage: fh( G)
1257
- ( False, ['a', 'b', 'c', 'd' ])
1255
+ ( False, [0, 1, 2, 3 ])
1258
1256
sage: G = G. reverse( )
1259
1257
sage: fh( G)
1260
- ( False, ['d', 'c', 'b', 'a' ])
1261
- sage: H = DiGraph( )
1262
- sage: H. add_cycle( 'abcdefgh')
1263
- sage: H. add_edge( 'dg')
1264
- sage: b, C = fh( H)
1265
- sage: b, len( C)
1266
- ( True, 8)
1267
- sage: H. delete_edge( 'ab')
1268
- sage: fh( H, find_path=False)
1269
- ( False, ['b', 'c', 'd', 'e', 'f', 'g', 'h', 'a' ])
1270
- sage: fh( H, find_path=True)
1271
- ( True, ['b', 'c', 'd', 'e', 'f', 'g', 'h', 'a' ])
1272
- sage: H. delete_edge( 'gh')
1273
- sage: fh( H, find_path=True)
1274
- ( False, ['b', 'c', 'd', 'e', 'f', 'g' ])
1258
+ ( False, [3, 2, 1, 0 ])
1259
+ sage: G = DiGraph( )
1260
+ sage: G. add_cycle( [0, 1, 2, 3, 4, 5 ])
1261
+ sage: b, P = fh( G)
1262
+ sage: b, len( P)
1263
+ ( True, 6)
1275
1264
1276
1265
TESTS:
1277
1266
0 commit comments