| 1 | initial version |
You can use the subgraph_search_iterator method:
sage: G = Graph([[0,1], [1,2], [2,3], [3,1], [2,4], [3,4], [4,5]])
sage: H = Graph([[0,1], [1,2], [2,3], [3,1]])
sage: list(G.subgraph_search_iterator(H))
[[0, 1, 2, 3],
[0, 1, 3, 2],
[1, 2, 3, 4],
[1, 2, 4, 3],
[1, 3, 2, 4],
[1, 3, 4, 2],
[4, 2, 1, 3],
[4, 2, 3, 1],
[4, 3, 1, 2],
[4, 3, 2, 1],
[5, 4, 2, 3],
[5, 4, 3, 2]]
Note that the order of the returned vertices is important.
Regarding cycles, you can have a look at the cycle_basis method, which gives you a compact representation of cycles:
sage: G.cycle_basis()
[[2, 3, 1], [2, 4, 3]]
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.