FDSRashid commited on
Commit
de7fc32
·
1 Parent(s): 0380f9d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -39,6 +39,7 @@ def network_visualizer(city, year, num_nodes):
39
  else:
40
  edge_15 = edges.copy()
41
  teacher_hadiths = edge_15[['Teacher', 'Hadiths']].groupby('Teacher').sum().reset_index()
 
42
  net = Network()
43
  # Create dictionaries to store node roles and colors based on attribute values
44
  node_roles = {}
@@ -51,10 +52,11 @@ def network_visualizer(city, year, num_nodes):
51
  attribute_value = row['Hadiths']
52
  edge_color = value_to_hex(attribute_value)
53
  hadith_count = teacher_hadiths[teacher_hadiths['Teacher'] == source]['Hadiths'].to_list()[0]
 
54
  edge_color = value_to_hex(attribute_value)
55
 
56
  net.add_node(source, color=value_to_hex(hadith_count), font = {'size':30, 'color': 'orange'}, label = f"{source}\nHadiths: {hadith_count}")
57
- net.add_node(target, color=value_to_hex(attribute_value) , font = {'size': 20, 'color': 'red'}, label = f"{target}\nHadiths: {attribute_value}")
58
  net.add_edge(source, target, color=edge_color, value=attribute_value)
59
 
60
 
 
39
  else:
40
  edge_15 = edges.copy()
41
  teacher_hadiths = edge_15[['Teacher', 'Hadiths']].groupby('Teacher').sum().reset_index()
42
+ student_hadiths = edge_15[['Student', 'Hadiths']].groupby('Student').sum().reset_index()
43
  net = Network()
44
  # Create dictionaries to store node roles and colors based on attribute values
45
  node_roles = {}
 
52
  attribute_value = row['Hadiths']
53
  edge_color = value_to_hex(attribute_value)
54
  hadith_count = teacher_hadiths[teacher_hadiths['Teacher'] == source]['Hadiths'].to_list()[0]
55
+ student_count = student_hadiths[student_hadiths['Student'] == target]['Hadiths'].to_list()[0]
56
  edge_color = value_to_hex(attribute_value)
57
 
58
  net.add_node(source, color=value_to_hex(hadith_count), font = {'size':30, 'color': 'orange'}, label = f"{source}\nHadiths: {hadith_count}")
59
+ net.add_node(target, color=value_to_hex(student_count) , font = {'size': 20, 'color': 'red'}, label = f"{target}\nHadiths: {student_count}")
60
  net.add_edge(source, target, color=edge_color, value=attribute_value)
61
 
62