-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjusttest.py
More file actions
43 lines (35 loc) · 1.56 KB
/
justtest.py
File metadata and controls
43 lines (35 loc) · 1.56 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
import pandas as pd
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
from Search_File_Content import Searching, first_patch, filedir
class Plotting:
def __init__(self,Network, DataFrame,Choosen_Module = None):
self.network = Network
self.dataframe = DataFrame
self.Filename = self.dataframe['Filename'].values.tolist()
self.Module = Choosen_Module
def networking(self):
weight = list()
nopy = [x[:x.rfind('.py')] for x in self.Filename]
for x in self.network['from'].values.tolist():
if x in nopy:
weight.append(3)
else:
weight.append(0.1)
self.network['weight'] =weight
if self.Module and self.Module in nopy:
df = self.network[self.network.to == self.Module] #Single Module
elif self.Module == 'OnlyMain':
df = self.network.iloc[[x for x in range(len(self.network))
if self.network.iloc[x]['from'] in nopy],:] # Main Module in Packages
else:
df= self.network
G = nx.from_pandas_edgelist(df=df, source='from',target = 'to', edge_attr='weight')
# Plot it
nx.draw(G, with_labels=True,node_size=150, node_color="skyblue", node_shape="s", alpha=0.5, linewidths=10)
plt.show()
Test1 = Searching(FirstHalfTable=first_patch,AllPyContainer=filedir)
table, nw = Test1.Merging()
test2 = Plotting(Network=nw, DataFrame=table, Choosen_Module='OnlyMain')
test2.networking()