initial stuff done
This commit is contained in:
@@ -3,37 +3,35 @@ import networkx as nx
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
parser=argparse.ArgumentParser(description='')
|
||||
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()
|
||||
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()
|
||||
sys.stderr.write('need graph and destroylist as argument -g and/or -m')
|
||||
exit(1)
|
||||
|
||||
D=[]
|
||||
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)]
|
||||
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())
|
||||
[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))
|
||||
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)] )
|
||||
print(len(D), [len(c) for c in sorted(nx.connected_components(G), key=len, reverse=True)])
|
||||
|
||||
Reference in New Issue
Block a user