upload exercise files

This commit is contained in:
Torma Kristóf 2020-09-24 12:49:49 +02:00
parent 9a1f60c68f
commit f94652791a
5 changed files with 3369 additions and 0 deletions

293
GBA100.txt Normal file
View File

@ -0,0 +1,293 @@
100
291
0 3
0 12
0 5
0 6
0 15
1 44
1 3
1 4
1 45
1 55
2 3
2 4
2 9
2 10
2 13
2 17
2 82
2 52
2 54
2 68
3 4
3 5
3 6
3 7
3 9
3 11
3 13
3 15
3 16
3 19
3 21
3 26
3 27
3 28
3 29
3 32
3 34
3 36
3 37
3 38
3 50
3 51
3 63
3 64
3 65
3 69
3 72
3 80
3 84
3 85
3 89
4 5
4 6
4 7
4 8
4 10
4 11
4 14
4 19
4 22
4 23
4 27
4 30
4 32
4 56
4 60
4 61
4 65
4 73
4 82
4 88
4 95
5 34
5 42
5 98
5 16
5 28
6 7
6 8
6 15
6 18
6 20
6 24
6 27
6 35
6 42
6 45
6 48
6 49
6 53
6 58
6 61
6 65
6 66
6 77
6 79
6 80
6 87
6 90
6 95
6 98
7 68
7 38
7 71
7 8
7 10
7 12
7 13
7 17
7 40
7 23
7 36
7 92
7 74
8 67
8 37
8 9
8 11
8 44
8 18
8 28
9 64
9 73
9 67
9 66
9 93
9 17
9 50
9 35
9 20
9 21
9 40
9 91
9 29
9 30
10 33
10 12
10 14
10 48
10 46
10 22
10 23
10 59
10 30
11 97
11 69
11 39
11 14
11 49
11 89
11 94
12 41
12 85
12 58
13 71
13 81
13 86
14 44
14 16
14 83
14 20
14 52
16 96
16 18
17 21
17 81
18 47
18 56
18 19
18 22
18 24
18 25
18 31
19 68
19 83
19 53
19 55
19 57
19 92
19 62
20 43
20 53
20 54
21 32
21 70
21 47
21 82
21 24
21 25
21 26
21 63
22 90
22 31
23 62
24 54
24 25
24 26
25 96
25 33
25 36
25 81
25 39
25 40
25 46
25 56
25 72
25 29
25 94
25 31
26 67
27 51
27 37
29 78
29 70
30 97
31 34
31 39
31 49
31 58
31 59
31 60
31 63
32 96
32 33
33 98
33 35
33 91
34 41
34 43
34 45
34 79
34 52
35 78
36 38
36 41
36 42
36 76
36 55
36 61
36 62
37 46
37 97
38 74
38 75
38 77
38 47
38 88
39 88
42 71
42 43
42 48
42 59
45 51
45 73
46 76
46 50
46 83
46 86
46 89
47 92
47 76
47 87
47 90
47 60
49 99
49 79
49 85
50 57
52 93
53 57
56 80
57 84
59 64
59 72
59 91
60 86
61 75
61 84
61 93
63 75
63 69
64 66
65 74
66 77
68 70
71 87
72 99
73 78
85 94
91 99
92 95

2993
GBA1000.txt Normal file

File diff suppressed because it is too large Load Diff

39
analyse_p3.py Normal file
View File

@ -0,0 +1,39 @@
import numpy as np
import networkx as nx
import argparse
import sys
parser=argparse.ArgumentParser(description='')
parser.add_argument('-g', '--graph', dest='graph', action='store', default=None)
parser.add_argument('-d', '--destroy', dest='destroy', action='store', default=None)
parser.add_argument('-n', '--node', dest='isnode', action='store_const', const=False, default = True)
args=parser.parse_args()
if not args.graph or not args.destroy:
print >> sys.stderr, 'need graph and destroylist as argument -g and/or -m'
exit()
D=[]
with open(args.destroy) as inf:
for line in inf:
D.append(int(line))
with open(args.graph) as ing:
n=int(ing.readline())
m=int(ing.readline())
A=[[0]*n for _ in range(n)]
for _ in range(m):
if not args.isnode:
if _ in D:
continue
[u,v]=map(int, ing.readline().split())
if args.isnode:
if u in D or v in D:
continue
A[u][v]=1
A[v][u]=1
G=nx.Graph(np.array(A))
print (len(D), [len(c) for c in sorted(nx.connected_components(G), key=len, reverse=True)] )

41
destroy_p3.py Normal file
View File

@ -0,0 +1,41 @@
import numpy as np
import networkx as nx
import argparse
parser=argparse.ArgumentParser(description='')
parser.add_argument('-g', '--graph', dest='graph', action='store', default=None)
args=parser.parse_args()
if not args.graph:
print ("need a graph as input")
exit()
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)]
for _ in range(m):
[u,v]=map(int, f.readline().split())
A[u][v]=1
A[v][u]=1
G=nx.Graph(np.array(A))
return G
def max_comp_size(G):
return max([len(c) for c in nx.connected_components(G)])
del_list=[]
G=read_graph(args.graph)
n=len(G.nodes)
while max_comp_size(G) > n/2:
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
for u in del_list:
print (u)

3
gba10d.txt Normal file
View File

@ -0,0 +1,3 @@
6
8
2