forked from ssjssh/algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
37 lines (26 loc) · 662 Bytes
/
test.py
File metadata and controls
37 lines (26 loc) · 662 Bytes
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
#!/usr/bin/env python
# -*- coding:UTF-8
__author__ = 'shenshijun'
class Node(object):
"""
带权图的中存储元素的节点
"""
def __init__(self, key, weight):
"""Constructor for """
self.key = key
self.weight = weight
def __cmp__(self, other):
return cmp(self.key, other.key)
def __hash__(self):
return hash(self.key)
def __str__(self):
return "".join(['Node(key=', str(self.key), ',weight=', str(self.weight), ")"])
__dict = {}
a1 = Node('A', 1)
a2 = Node('A', 2)
__dict[a1] = a1
print(a1 == a2)
print(a2 in __dict)
print(__dict.get(a2))
import sys
print(sys.version)