-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.py
More file actions
61 lines (44 loc) · 1.49 KB
/
testing.py
File metadata and controls
61 lines (44 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 28 12:29:35 2018
@author: kristianeschenburg
"""
import numpy as np
"""
h = np.arange(5).astype(np.int32)
r = np.arange(15).astype(np.int32)
hr = np.zeros((5,15)).astype(np.int32)
rr = np.zeros((15,5)).astype(np.int32)
for hp in np.arange(5):
hr[hp,:] = np.random.choice(15,size=(15,),replace=False).astype(np.int32)
for rp in np.arange(15):
rr[rp,:] = np.random.choice(5,size=(5,),replace=False).astype(np.int32)
positions = np.asarray([3,2,1,2,1])
"""
m = np.asarray([0,1]).astype(np.int32)
w = np.asarray([0,1]).astype(np.int32)
mp = np.asarray([[0,1],
[1,0]]).astype(np.int32)
wp = np.asarray([[0,1],
[1,0]]).astype(np.int32)
import Graphs as gm
#G = gm.ResidentMatching(h,r,positions,hr,rr)
#G.match()
#G = gm.GaleShapely(m,w,mp,wp)
#G.marry()
H = np.asarray([[0,1,0,0,1,0,0,0],[0,0,1,0,0,0,1,0],[0,0,0,1,0,0,0,0],
[0,0,0,0,0,0,0,1],[0,0,0,0,0,1,0,0],[0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,1],[0,0,0,0,0,0,0,0]])
C = np.asarray([[0,10,0,0,10,0,0,0],[0,0,10,0,0,0,1,0],[0,0,0,10,0,0,0,0],
[0,0,0,0,0,0,0,10],[0,0,0,0,0,10,0,0],[0,0,0,0,0,0,10,0],
[0,0,0,0,0,0,0,10],[0,0,0,0,0,0,0,0]])
G = gm.EdmondsKarp(C,H)
G.edmondskarp()
print 'Max flow: {}'.format(G.maxFlow)
H = np.zeros((6,6))
H[0:3,0:3] = 1
H[3:6,3:6] = 1
[nc,components] = gm.connected_components(H)
print '# Components = : {}'.format(nc)
print components