Ask Your Question
0

Finding a spanning subgraph that satisfies a given condition

asked 2025-07-11 06:35:57 +0100

licheng gravatar image

updated 2025-07-11 06:41:25 +0100

Finding a spanning subgraph that satisfies a given condition is NP-hard. My goal is to find a 4-connected planar spanning subgraph of a given graph. I tried writing the following code, but its efficiency is poor, since it enumerates even disconnected spanning subgraphs. I'm wondering whether there are any improvements that could be made to make the algorithm more efficient—at least to make it work on the following specific graph (constructed by drawing a pentagram inside each face of an dodecahedron).

image description

g=Graph({0: [1, 2, 18, 19, 3, 8, 9, 10, 11],
 1: [0, 2, 3, 19, 6, 7, 8, 9, 10],
 2: [0, 1, 3, 19, 4, 5, 6, 7, 8],
 3: [0, 1, 17, 2, 18, 19, 4, 5, 6],
 4: [16, 17, 2, 18, 3, 19, 5, 6, 15],
 5: [16, 17, 2, 3, 4, 6, 7, 14, 15],
 6: [1, 2, 3, 4, 5, 7, 8, 14, 15],
 7: [1, 2, 5, 6, 8, 9, 13, 14, 15],
 8: [0, 1, 2, 6, 7, 9, 10, 13, 14],
 9: [0, 1, 7, 8, 10, 11, 12, 13, 14],

 10: [0, 1, 18, 19, 8, 9, 11, 12, 13],
 11: [0, 16, 17, 18, 19, 9, 10, 12, 13],
 12: [16, 17, 18, 9, 10, 11, 13, 14, 15],
 13: [16, 7, 8, 9, 10, 11, 12, 14, 15],
 14: [16, 5, 6, 7, 8, 9, 12, 13, 15],
 15: [16, 17, 4, 5, 6, 7, 12, 13, 14],

 16: [17, 18, 4, 5, 11, 12, 13, 14, 15],
 17: [16, 18, 3, 19, 4, 5, 11, 12, 15],
 18: [0, 16, 17, 19, 3, 4, 10, 11, 12],
 19: [0, 1, 17, 18, 2, 3, 4, 10, 11]})

def find_one_planar_spanning_subgraph_with_connectivity_at_least(G, k):
    """
    Search for one spanning subgraph of G that is:
        - connected,
        - planar,
        - and has vertex connectivity at least k.

    Parameters:
        G: A SageMath graph.
        k: Minimum required vertex connectivity.

    Returns:
        A graph H (spanning subgraph of G) satisfying all conditions, or None if none exists.
    """
    edges = G.edges(labels=False)
    n = len(edges)

    for i in range(2^n):
        selected_edges = [edges[j] for j in range(n) if (i >> j) & 1]

        H = Graph()
        H.add_vertices(G.vertices())
        H.add_edges(selected_edges)

        # Check all conditions
        if H.is_planar() and H.vertex_connectivity() >= k:
            return H

    return None
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2025-12-31 19:57:07 +0100

This graph has m=90 edges so counting from 0 to 2^m will not finish in your lifetime. Exhaustive search is only feasible up to 30 edges.

Your specific problem (finding a 4-connected planar spanning subgraph) can be solved in a few seconds by guessing subgraphs using plantri:

from sage.graphs.generic_graph_pyx import SubgraphSearch

G = Graph("S~KzzNbo]@oB?F?^_}W]FB@{[E[o[^oWK")
for H in graphs.plantri_gen(f"{G.order()} -pc4"):
    for _ in SubgraphSearch(G, H):
        return H
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

Asked: 2025-07-11 06:35:57 +0100

Seen: 1,014 times

Last updated: Jul 11 '25