Classes
GraphAnalyzer
Analyzes knowledge graph structure for page connectivity insights.
Provides methods for:
- Connect…
GraphAnalyzer
Analyzes knowledge graph structure for page connectivity insights.
Provides methods for:
- Connectivity scoring (incoming + outgoing refs)
- Hub detection (highly connected pages)
- Leaf detection (low connectivity pages)
- Orphan detection (no connections)
- Layer partitioning (for hub-first streaming builds)
Methods 6
get_connectivity
Get connectivity information for a specific page.
get_connectivity
def get_connectivity(self, page: Page) -> PageConnectivity
Get connectivity information for a specific page.
Parameters 1
page |
Page |
Page to analyze |
Returns
PageConnectivity with detailed metricsPageConnectivity
—
get_connectivity_score
Get total connectivity score for a page.
Connectivity = incoming_refs + outgoi…
get_connectivity_score
def get_connectivity_score(self, page: Page) -> int
Get total connectivity score for a page.
Connectivity = incoming_refs + outgoing_refs
Parameters 1
page |
Page |
Page to analyze |
Returns
Connectivity score (higher = more connected)int
—
get_hubs
Get hub pages (highly connected pages).
Hubs are pages with many incoming refe…
get_hubs
def get_hubs(self, threshold: int | None = None) -> list[Page]
Get hub pages (highly connected pages).
Hubs are pages with many incoming references. These are typically:
- Index pages
- Popular articles
- Core documentation
Parameters 1
threshold |
int | None |
Minimum incoming refs (defaults to graph.hub_threshold) |
Returns
List of hub pages sorted by incoming references (descending)list[Page]
—
get_leaves
Get leaf pages (low connectivity pages).
Leaves are pages with few connections…
get_leaves
def get_leaves(self, threshold: int | None = None) -> list[Page]
Get leaf pages (low connectivity pages).
Leaves are pages with few connections. These are typically:
- One-off blog posts
- Changelog entries
- Niche content
Parameters 1
threshold |
int | None |
Maximum connectivity (defaults to graph.leaf_threshold) |
Returns
List of leaf pages sorted by connectivity (ascending)list[Page]
—
get_orphans
Get orphaned pages (no connections at all).
Orphans are pages with no incoming…
get_orphans
def get_orphans(self) -> list[Page]
Get orphaned pages (no connections at all).
Orphans are pages with no incoming or outgoing references. These might be:
- Forgotten content
- Draft pages
- Pages that should be linked from navigation
Returns
List of orphaned pages sorted by sluglist[Page]
—
get_layers
Partition pages into three layers by connectivity.
Layers enable hub-first str…
get_layers
def get_layers(self) -> PageLayers
Partition pages into three layers by connectivity.
Layers enable hub-first streaming builds:
- Layer 0 (Hubs): High connectivity, process first, keep in memory
- Layer 1 (Mid-tier): Medium connectivity, batch processing
- Layer 2 (Leaves): Low connectivity, stream and release
Returns
PageLayers dataclass with hubs, mid_tier, and leaves attributes
(supports tuple unpacking for backward compatibility)PageLayers
—
Internal Methods 2
__init__
Initialize the graph analyzer.
__init__
def __init__(self, graph: KnowledgeGraph) -> None
Initialize the graph analyzer.
Parameters 1
graph |
KnowledgeGraph |
Knowledge graph to analyze (must be built) |
_ensure_built
Verify the graph has been built before analysis.
_ensure_built
def _ensure_built(self) -> None
Verify the graph has been built before analysis.