kaushikacharya commited on
Commit
6517aa8
·
1 Parent(s): 730e728

Interactive Graph: Mouse hover nodes and edges displays description in pop-up window

Browse files
Files changed (1) hide show
  1. examples/graph_visual_with_html.py +8 -1
examples/graph_visual_with_html.py CHANGED
@@ -11,9 +11,16 @@ net = Network(height="100vh", notebook=True)
11
  # Convert NetworkX graph to Pyvis network
12
  net.from_nx(G)
13
 
14
- # Add colors to nodes
15
  for node in net.nodes:
16
  node["color"] = "#{:06x}".format(random.randint(0, 0xFFFFFF))
 
 
 
 
 
 
 
17
 
18
  # Save and display the network
19
  net.show("knowledge_graph.html")
 
11
  # Convert NetworkX graph to Pyvis network
12
  net.from_nx(G)
13
 
14
+ # Add colors and title to nodes
15
  for node in net.nodes:
16
  node["color"] = "#{:06x}".format(random.randint(0, 0xFFFFFF))
17
+ if "description" in node:
18
+ node["title"] = node["description"]
19
+
20
+ # Add title to edges
21
+ for edge in net.edges:
22
+ if "description" in edge:
23
+ edge["title"] = edge["description"]
24
 
25
  # Save and display the network
26
  net.show("knowledge_graph.html")