Compare commits

...

6 Commits

Author SHA1 Message Date
61e414a3ce multiple pipelines 2020-09-24 15:55:08 +02:00
dd43985224 duplicate step names 2020-09-24 15:53:19 +02:00
23cb722cd9 fix yaml
Some checks reported errors
continuous-integration/drone/push Build encountered an error
2020-09-24 15:53:03 +02:00
602f7d4f1b kebab 2020-09-24 15:52:07 +02:00
ca44105fae use connected components
Some checks reported errors
continuous-integration/drone/push Build encountered an error
2020-09-24 14:07:58 +02:00
0c4842a6f5 use minimum node cut
Some checks failed
continuous-integration/drone/push Build is failing
2020-09-24 13:53:44 +02:00
2 changed files with 52 additions and 17 deletions

View File

@ -1,9 +1,21 @@
kind: pipeline
type: docker
name: default
name: run_algo
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"
commands:
- pip3 install -r requirements.txt

View File

@ -13,9 +13,9 @@ if not args.graph:
def read_graph(graph_file):
with open(graph_file) as f:
n = int(f.readline())
m = int(f.readline())
A = [[0] * n for _ in range(n)]
n = int(f.readline()) # pontok száma
m = int(f.readline()) # élek száma
A = [[0] * n for _ in range(n)] # táblázat, ahol az élek helyén 1 van, ammeg 0
for _ in range(m):
[u, v] = map(int, f.readline().split())
A[u][v] = 1
@ -24,21 +24,44 @@ def read_graph(graph_file):
return G
input_graph = read_graph(args.graph)
def max_comp_size(G):
return max([len(c) for c in nx.connected_components(G)])
def run_random_once() -> list:
del_list = []
G = read_graph(args.graph)
n = len(G.nodes)
while max_comp_size(G) > n / 2:
G = input_graph.copy()
target = len(G.nodes) / 2
while max_comp_size(G) > target:
u = np.random.choice(G.nodes)
if u not in del_list:
del_list.append(u)
G.remove_node(u)
# print len(del_list), del_list
return del_list
for u in del_list:
print(u)
def remove_highest_kebab() -> list:
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)