Skip to content

Commit

Permalink
change list to set for performance improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Xuefeng-Zhu committed May 11, 2015
1 parent e653c6e commit c55ad5f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions graphs/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def get_edge_weights(self):
unique_list = {}
for u in self.nodes():
for v in self.neighbors(u):
if u not in unique_list.get(v, []):
if u not in unique_list.get(v, set()):
edge_list.append((self.node_neighbors[u][v], (u, v)))
unique_list.setdefault(u, []).append(v)
unique_list.setdefault(u, set()).add(v)
return edge_list

0 comments on commit c55ad5f

Please sign in to comment.