Question Details

No question body available.

Tags

python graph partitioning implementation data-science-experience

Answers (1)

April 18, 2026 Score: 5 Rep: 552 Quality: Medium Completeness: 100%

regarding your questions:

  1. it's a correct way implementing in O(E) since in in set takes O(1) cause of hash table.

  2. there are many built-in functions in NetworkX such edgeboundary(G1, group1, group2) , and you could use them in code :

    import networkx as nx

    G = nx.Graph() edges = [(1, 2), (1, 3), (2, 3), (4, 5), (5, 6), (4, 6), (7, 8), (8, 9), (9, 7), (10, 11), (3, 4), (6, 7), (9, 10)] G.addedgesfrom(edges)

    group1 = {1, 2, 3, 4, 5} group2 = {6, 7, 8, 9, 10, 11}

    cutedges = list(nx.edgeboundary(G, group1, group2)) print(cutedges)

  3. to automatically find balanced partitions use the graph partitioning algorithms

    maxflow-mincut-theorem, Minimum Cut - Stoer–Wagner algorithm and Multilevel partitioning (METIS)