| 1 | initial version |
Unless there is a better idea, one can iterate over all cycles in the graph as explained at https://ask.sagemath.org/question/69318/find-all-cycles-in-an-undirected-graph/ and keep track what vertices are visited by cycles of what length.
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.