-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasegraph.py
More file actions
105 lines (102 loc) · 2.23 KB
/
basegraph.py
File metadata and controls
105 lines (102 loc) · 2.23 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
class Forward_chaining():
def __init__(self, graph):
self.graph = graph
def bastard(child):
aux = graph.get('henryVIII')
esposas = aux.get('spouse')
mae = ''
if(child in aux.get('parent')):
for keys in graph.keys():
if key != 'henryVIII' and child in key.get('parent'):
mae = key
else:
print("child not found")
return
if(mae in esposas):
return False
else:
return True
graph = {
'henryVIII': {
'spouse': [
'catherineparr', 'janeseymour', 'catherineofaragon', 'anneboleyn', 'catherinehoward', 'anneofcleves'
],
'sex': 'male',
'relationships': [
'catherineparr', 'janeseymour', 'catherineofaragon', 'anneboleyn', 'catherinehoward', 'anneofcleves',
'isabelblount'
],
'parent': [
'henryfitzroy', 'elizabethI', 'maryI', 'edwardVI'
],
'successor': [
'edwardVI'
],
'issue': [
'henryfitzroy', 'elizabethI', 'maryI', 'edwardVI'
]
},
'henryVII': {
'spouse': [
'elizabethofyork'
],
'sex': 'male',
'parent': [
'henryVIII'
],
'sucessor': [
'henryVIII'
]
},
'catherineofaragon': {
'parent': [
'maryI'
],
'sex': 'female',
'issue': [
'maryI'
]
},
'anneboleyn': {
'parent': [
'elizabethI'
],
'sex': 'female',
'issue': [
'elizabethI'
]
},
'janeseymour': {
'parent': [
'edwardVI'
],
'sex': 'female',
'issue': [
'edwardVI'
]
},
'elizabethofyork': {
'parent': [
'henryVIII'
],
'sex': 'female',
'issue': [
'henryVIII'
]
},
'maryI': {
'sucessor': [
'elizabethI'
],
'sex': 'female'
},
'elizabethI': {
'sex': 'female'
},
'henryfitzroy': {
'sex': 'female'
},
'edwardVI': {
'sex': 'male'
}
}