-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraphinPython.py
49 lines (33 loc) · 1000 Bytes
/
graphinPython.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class node:
def __init__(self , value):
self.value = value
self.manes = []
self.weigth = None
def re(self):
return ([self.value , self.manes , self.weigth ])
isinstance = 0
class addNode:
def __init__(self):
global isinstance
print (isinstance)
self.manes = []
if (isinstance==1):
raise Exception('you cant make the more than one instance from this object ... ')
else :
isinstance+=1
def add(self , value , manes , weigth):
print(value , manes , weigth)
nodeIns = node(value)
nodeIns.manes = manes
nodeIns.weigth = weigth
print(nodeIns.re())
self.manes.append(nodeIns.re())
def __repr__(self):
return (f'${self.manes}')
nnn = addNode()
# nnn2 = addNode()
newNode = nnn.add("a" , [""] , 1 )
newNode2 = nnn.add("b" , ["a"] , 2)
newNode = nnn.add("c" , ["a" , "b"] , 3)
# newNode5 = nnn.add("c" )
print (nnn)