MCPcopy Create free account
hub / github.com/Surfer-Org/Protocol / display_graph

Function display_graph

cookbook/python/knowledge-graph/app.py:22–44  ·  view source on GitHub ↗
(G, title)

Source from the content-addressed store, hash-verified

20net.show_buttons(filter_=['physics'])
21
22def display_graph(G, title):
23 # Update Pyvis network
24 net.from_nx(G)
25
26 # Configure node and edge appearance
27 for node in net.nodes:
28 node.update({
29 'size': 25,
30 'label': G.nodes[node['id']].get('label', ''),
31 'title': G.nodes[node['id']].get('text', ''), # Hover text
32 'color': '#6AACF0',
33 'value': len([n for n in G.neighbors(node['id'])]) # Node size based on connections
34 })
35
36 for edge in net.edges:
37 edge.update({
38 'label': G.edges[edge['from'], edge['to']].get('label', ''),
39 'width': 2,
40 'font': {'size': 10}
41 })
42
43 # Save interactive HTML with a fixed filename during processing
44 net.save_graph('graph_current.html')
45
46def save_graph(G):
47 timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")

Callers 1

app.pyFile · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected