kebab
This commit is contained in:
parent
ca44105fae
commit
602f7d4f1b
@ -3,7 +3,12 @@ type: docker
|
|||||||
name: default
|
name: default
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: run_tournament
|
- name: check_result
|
||||||
|
image: "python:3.8"
|
||||||
|
commands:
|
||||||
|
- pip3 install -r requirements.txt
|
||||||
|
- python3 destroy_p3.py -g GBA1000.txt
|
||||||
|
- name: check_result
|
||||||
image: "python:3.8"
|
image: "python:3.8"
|
||||||
commands:
|
commands:
|
||||||
- pip3 install -r requirements.txt
|
- pip3 install -r requirements.txt
|
||||||
|
@ -13,9 +13,9 @@ if not args.graph:
|
|||||||
|
|
||||||
def read_graph(graph_file):
|
def read_graph(graph_file):
|
||||||
with open(graph_file) as f:
|
with open(graph_file) as f:
|
||||||
n = int(f.readline())
|
n = int(f.readline()) # pontok száma
|
||||||
m = int(f.readline())
|
m = int(f.readline()) # élek száma
|
||||||
A = [[0] * n for _ in range(n)]
|
A = [[0] * n for _ in range(n)] # táblázat, ahol az élek helyén 1 van, ammeg 0
|
||||||
for _ in range(m):
|
for _ in range(m):
|
||||||
[u, v] = map(int, f.readline().split())
|
[u, v] = map(int, f.readline().split())
|
||||||
A[u][v] = 1
|
A[u][v] = 1
|
||||||
@ -24,19 +24,44 @@ def read_graph(graph_file):
|
|||||||
return G
|
return G
|
||||||
|
|
||||||
|
|
||||||
|
input_graph = read_graph(args.graph)
|
||||||
|
|
||||||
|
|
||||||
def max_comp_size(G):
|
def max_comp_size(G):
|
||||||
return max([len(c) for c in nx.connected_components(G)])
|
return max([len(c) for c in nx.connected_components(G)])
|
||||||
|
|
||||||
|
|
||||||
|
def run_random_once() -> list:
|
||||||
del_list = []
|
del_list = []
|
||||||
G = read_graph(args.graph)
|
G = input_graph.copy()
|
||||||
n = len(G.nodes)
|
target = len(G.nodes) / 2
|
||||||
while max_comp_size(G) > n / 2:
|
while max_comp_size(G) > target:
|
||||||
H = max((G.subgraph(c) for c in nx.connected_components(G)), key=len)
|
u = np.random.choice(G.nodes)
|
||||||
mnc = nx.minimum_node_cut(G=H)
|
if u not in del_list:
|
||||||
del_list.append(mnc)
|
del_list.append(u)
|
||||||
G.remove_nodes_from(mnc)
|
G.remove_node(u)
|
||||||
|
|
||||||
|
return del_list
|
||||||
|
|
||||||
|
|
||||||
for u in del_list:
|
def remove_highest_kebab() -> list:
|
||||||
print(u)
|
del_list = []
|
||||||
|
G = input_graph.copy()
|
||||||
|
target = len(G.nodes) / 2
|
||||||
|
|
||||||
|
while max_comp_size(G) > target:
|
||||||
|
highest_node = None
|
||||||
|
highest_node_deg = 0
|
||||||
|
for node in G.nodes:
|
||||||
|
if G.degree[node] > highest_node_deg:
|
||||||
|
highest_node = node
|
||||||
|
highest_node_deg = G.degree[node]
|
||||||
|
|
||||||
|
del_list.append(highest_node)
|
||||||
|
G.remove_node(highest_node)
|
||||||
|
|
||||||
|
return del_list
|
||||||
|
|
||||||
|
|
||||||
|
for kebab in remove_highest_kebab():
|
||||||
|
print(kebab)
|
||||||
|
Loading…
Reference in New Issue
Block a user