Processing math: 100%
Ask Your Question
0

Test if a graph is vertex pancyclic

asked 0 years ago

licheng gravatar image

updated 0 years ago

Let G be a graph of order n. A graph G is called pancyclic if it contains a cycle of length k for every 3kn, and it is called vertex pancyclic if every vertex is contained in a cycle of length k for every 3kn.

For vertex-pancyclic graphs, we can use a subgraph search approach (as shown below).

def pancyclic(G):
    for a in range(3, G.order() + 1):  # Check for cycles of length 3 to n
        if G.subgraph_search(graphs.CycleGraph(a)) is None:
            return False  # Return False immediately if a cycle of length a is missing
    return True  # Return True if cycles of all lengths are found

However, for vertex-pancyclicity, do we have a better method? The core step is determining whether a given vertex lies on a cycle of given length. Clearly a vertex pancyclic graph is pancyclic. However, the converse is not true. The following is an example since the vertex 6 does not lie any cycle of length 3.

G = Graph([(0, 1), (0, 2), (0, 3), (1, 3), (2, 3),{1,4},{3,4},{3,5},{2,5},{4,6},{5,6}])

Note that if a vertex is in a k-cycle, then the vertices on this cycle do not need to be verified again for being in a k-cycle, reducing redundant computations.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 0 years ago

Max Alekseyev gravatar image

Unless there is a better idea, one can iterate over all cycles in the graph as explained at https://ask.sagemath.org/question/693... and keep track what vertices are visited by cycles of what length.

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 0 years ago

Seen: 42 times

Last updated: Mar 18