Эх сурвалжийг харах

Merge branch 'master' of git.heuristics.ml:jkunlin/little_tools

jkunlin 8 жил өмнө
parent
commit
a2174936ef
1 өөрчлөгдсөн 2 нэмэгдсэн , 2 устгасан
  1. 2 2
      graphml2dimacs.py

+ 2 - 2
graphml2dimacs.py

@@ -24,7 +24,7 @@ for elem in root:
     if elem.tag == namespace + 'node':
         # print (elem.attrib['id'], " weight: ")
         node_map[elem.attrib['id']] = nodex_index
-        while len(adjacency_list) < nodex_index:
+        while len(adjacency_list) - 1 < nodex_index:
             adjacency_list.append([])
         nodex_index += 1
 
@@ -33,7 +33,7 @@ for elem in root:
             # print (sub_elem.attrib['key'])
             if sub_elem.attrib['key'] == weight_id:
                 # print (sub_elem.text)
-                node_weight.append(int(sub_elem.text))
+                node_weight.append(int(float(sub_elem.text)))
     # get edge
     elif elem.tag == namespace + 'edge':
         source_index = node_map[elem.attrib['source']]