-
Notifications
You must be signed in to change notification settings - Fork 0
/
InitializingNodesAndEdges.py
28 lines (24 loc) · 1.03 KB
/
InitializingNodesAndEdges.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
class InitializeNodesAndEdges:
def __init__(self, All_dfs, fk):
self.All_dfs = All_dfs
self.fk = fk
self.nodes = set()
self.edges = set()
self.properties = set()
self.convert_using_naming()
self.nodes_edges(fk)
def convert_using_naming(self):
nodesNames = ('supplier', 'customer', 'retailer','service providers', 'distributors', 'sales channels', 'consumers', 'producers', 'vendors', 'transportation', 'wholesaler', 'distribution center', 'warehouses')
for name in list(self.All_dfs.keys()):
lowerCasedName = name.lower()
if(lowerCasedName in nodesNames):
self.nodes.add(lowerCasedName)
def nodes_edges(self, fk):
for f in fk:
if(f not in ['ssintorders','manufacturing']):
if len(fk[f]) == 2:
self.edges.add(f)
elif len(fk[f]) == 1:
self.properties.add(f)
# elif len(fk[f]) == 0:
# nodes.add(f)