Compare commits
6 Commits
kebab
...
61e414a3ce
Author | SHA1 | Date | |
---|---|---|---|
61e414a3ce
|
|||
dd43985224
|
|||
23cb722cd9
|
|||
602f7d4f1b
|
|||
ca44105fae
|
|||
0c4842a6f5
|
18
.drone.yml
18
.drone.yml
@ -1,11 +1,23 @@
|
|||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: default
|
name: run_algo
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: run_tournament
|
- name: algo
|
||||||
|
image: "python:3.8"
|
||||||
|
commands:
|
||||||
|
- pip3 install -r requirements.txt
|
||||||
|
- python3 destroy_p3.py -g GBA1000.txt
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: check_result
|
||||||
|
|
||||||
|
- name: result
|
||||||
image: "python:3.8"
|
image: "python:3.8"
|
||||||
commands:
|
commands:
|
||||||
- pip3 install -r requirements.txt
|
- pip3 install -r requirements.txt
|
||||||
- python3 destroy_p3.py -g GBA1000.txt > gba1000d.txt
|
- python3 destroy_p3.py -g GBA1000.txt > gba1000d.txt
|
||||||
- python3 analyse_p3.py -g GBA1000.txt -d gba1000d.txt
|
- python3 analyse_p3.py -g GBA1000.txt -d gba1000d.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,21 +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)])
|
||||||
|
|
||||||
|
|
||||||
del_list = []
|
def run_random_once() -> list:
|
||||||
G = read_graph(args.graph)
|
del_list = []
|
||||||
n = len(G.nodes)
|
G = input_graph.copy()
|
||||||
while max_comp_size(G) > n / 2:
|
target = len(G.nodes) / 2
|
||||||
u = np.random.choice(G.nodes)
|
while max_comp_size(G) > target:
|
||||||
if u not in del_list:
|
u = np.random.choice(G.nodes)
|
||||||
del_list.append(u)
|
if u not in del_list:
|
||||||
G.remove_node(u)
|
del_list.append(u)
|
||||||
|
G.remove_node(u)
|
||||||
|
|
||||||
# print len(del_list), del_list
|
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)
|
||||||
|
Reference in New Issue
Block a user