Skip to content

src/visualize

Phase 5 module for generating interactive HTML visualizations.

Functions

build_networkx_graph(graph_json_path: str) → nx.DiGraph

Load a knowledge graph from a JSON file into a NetworkX DiGraph.

Parameters:

Name Type Description
graph_json_path str Path to knowledge_graph.json

Returns: NetworkX directed graph.


create_network_viz(G: nx.DiGraph, output_path: str) → None

Generate an interactive force-directed network graph using Pyvis.

Parameters:

Name Type Description
G nx.DiGraph Knowledge graph
output_path str Output HTML file path

Features:

  • Nodes colored by type (gold=Laureate, light blue=Work, green=Concept, orange=Award, purple=Field)
  • Node sizes scaled by degree
  • CROSS_INSPIRED edges highlighted in red with increased width
  • Barnes-Hut physics simulation for layout
  • HTML legend overlay

create_timeline_viz(G: nx.DiGraph, output_path: str) → None

Generate a timeline scatter plot of concepts using Plotly.

Parameters:

Name Type Description
G nx.DiGraph Knowledge graph
output_path str Output HTML file path

Features:

  • X-axis: Year, Y-axis: Field
  • Marker size scaled by connection count
  • Red arrow annotations for CROSS_INSPIRED edges
  • Hover text with concept details

create_heatmap_viz(G: nx.DiGraph, output_path: str) → None

Generate a field-to-field cross-discipline heatmap using Plotly.

Parameters:

Name Type Description
G nx.DiGraph Knowledge graph
output_path str Output HTML file path

Features:

  • Square matrix of source field × target field
  • YlOrRd color scale
  • Hover showing exact migration count

run() → None

Execute the full Phase 5 pipeline:

  1. Load configuration
  2. Build graph from JSON
  3. Generate network.html
  4. Generate timeline.html
  5. Generate heatmap.html