make graph visualization become colorful
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import networkx as nx
|
import networkx as nx
|
||||||
from pyvis.network import Network
|
from pyvis.network import Network
|
||||||
|
import random
|
||||||
|
|
||||||
# Load the GraphML file
|
# Load the GraphML file
|
||||||
G = nx.read_graphml('./dickens/graph_chunk_entity_relation.graphml')
|
G = nx.read_graphml('./dickens/graph_chunk_entity_relation.graphml')
|
||||||
@@ -10,5 +11,9 @@ net = Network(notebook=True)
|
|||||||
# Convert NetworkX graph to Pyvis network
|
# Convert NetworkX graph to Pyvis network
|
||||||
net.from_nx(G)
|
net.from_nx(G)
|
||||||
|
|
||||||
|
# Add colors to nodes
|
||||||
|
for node in net.nodes:
|
||||||
|
node['color'] = "#{:06x}".format(random.randint(0, 0xFFFFFF))
|
||||||
|
|
||||||
# Save and display the network
|
# Save and display the network
|
||||||
net.show('knowledge_graph.html')
|
net.show('knowledge_graph.html')
|
Reference in New Issue
Block a user