pub struct SubgraphSummarizer;Expand description
Produces cluster-based summaries of KG subgraphs.
Implementations§
Source§impl SubgraphSummarizer
impl SubgraphSummarizer
Sourcepub fn summarize(
&self,
graph: &KgSubgraph,
max_clusters: usize,
) -> Vec<SummaryCluster>
pub fn summarize( &self, graph: &KgSubgraph, max_clusters: usize, ) -> Vec<SummaryCluster>
Summarise graph into at most max_clusters SummaryClusters.
§Algorithm
- Group nodes by
node_type. - If there are more types than
max_clusters, merge the smallest groups into an"Other"cluster so that onlymax_clustersremain. - For each cluster, count internal edges and pick the most-connected node (highest undirected degree within the whole graph) as the representative.
Sourcepub fn extract_key_relations(
&self,
graph: &KgSubgraph,
top_n: usize,
) -> Vec<(String, usize)>
pub fn extract_key_relations( &self, graph: &KgSubgraph, top_n: usize, ) -> Vec<(String, usize)>
Return the top-top_n relation types by frequency of occurrence.
Ties are broken by relation name (alphabetical ascending).
Sourcepub fn node_degree(&self, graph: &KgSubgraph, node_id: &str) -> usize
pub fn node_degree(&self, graph: &KgSubgraph, node_id: &str) -> usize
Compute the undirected degree of node_id in graph.
Both outgoing and incoming edges are counted (a self-loop counts twice).
Sourcepub fn generate_text_summary(&self, clusters: &[SummaryCluster]) -> String
pub fn generate_text_summary(&self, clusters: &[SummaryCluster]) -> String
Generate a human-readable summary paragraph from a set of clusters.
The paragraph lists each cluster’s representative node, member count, and internal edge count, ending with the total number of clusters.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SubgraphSummarizer
impl RefUnwindSafe for SubgraphSummarizer
impl Send for SubgraphSummarizer
impl Sync for SubgraphSummarizer
impl Unpin for SubgraphSummarizer
impl UnsafeUnpin for SubgraphSummarizer
impl UnwindSafe for SubgraphSummarizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more