-
Notifications
You must be signed in to change notification settings - Fork 1
/
find.py
31 lines (16 loc) · 844 Bytes
/
find.py
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
import xml.etree.ElementTree as ET
import os
ns = {'n':'http://graphml.graphdrawing.org/xmlns'} #namespace
arc = []
for file1 in os.listdir("DatasetGraphml"):#legge le mappe dentro la cartella Map
if file1.endswith(".graphml"):
#print(file1)
tree = ET.parse("DatasetGraphml"+os.sep+file1)
root = tree.getroot()
listOfNodes = root.findall('.//n:graph/n:node[@id]',ns)
listofArc = root.findall('.//n:graph/n:edge[@source][@target]',ns)
arc.append([len(listOfNodes)/len(listofArc),file1,len(listofArc),len(listOfNodes)])
# print("nome: "+file1+" numero nodi: "+ str(len(listOfNodes))+" numero archi : "+ str(len(listofArc)))
new = sorted(arc, key=lambda x: x[0], reverse=False)
for x in new:
print(str(x[0])," "+x[1]+" "+str(x[2])+" "+str(x[3]))