Summarize Graph¶
The Summarize Graph operation takes an instance of kgx.graph.base_graph.BaseGraph
and
generates summary statistics for the entire graph.
This operation generates summary as a YAML in a format that is compatible with the Knowledge Graph Hub dashboard.
The main entry point is the kgx.graph_operations.summarize_graph.generate_graph_stats
method.
Note: To generate a summary statistics YAML that is consistent with Translator API (TRAPI) standards, refer to Knowledge Map operation.
kgx.graph_operations.summarize_graph¶
-
kgx.graph_operations.summarize_graph.
generate_graph_stats
(graph: kgx.graph.base_graph.BaseGraph, graph_name: str, filename: str, node_facet_properties: Optional[List] = None, edge_facet_properties: Optional[List] = None) → None[source]¶ Generate stats from Graph.
- Parameters
graph (kgx.graph.base_graph.BaseGraph) – The graph
graph_name (str) – Name for the graph
filename (str) – Filename to write the stats to
node_facet_properties (Optional[List]) – A list of properties to facet on. For example,
['provided_by']
edge_facet_properties (Optional[List]) – A list of properties to facet on. For example,
['provided_by']
-
kgx.graph_operations.summarize_graph.
get_facet_counts
(data: Dict, stats: Dict, x: str, y: str, facet_property: str) → Dict[source]¶ Facet on
facet_property
and record the count forstats[x][y][facet_property]
.- Parameters
data (dict) – Node/edge data dictionary
stats (dict) – The stats dictionary
x (str) – first key
y (str) – second key
facet_property (str) – The property to facet on
- Returns
The stats dictionary
- Return type
Dict
-
kgx.graph_operations.summarize_graph.
summarize_edges
(graph: kgx.graph.base_graph.BaseGraph, facet_properties: Optional[List] = None) → Dict[source]¶ Summarize the edges in a graph.
- Parameters
graph (kgx.graph.base_graph.BaseGraph) – The graph
facet_properties (Optional[List]) – The properties to facet on
- Returns
The edge stats
- Return type
Dict
-
kgx.graph_operations.summarize_graph.
summarize_graph
(graph: kgx.graph.base_graph.BaseGraph, name: str = None, node_facet_properties: Optional[List] = None, edge_facet_properties: Optional[List] = None) → Dict[source]¶ Summarize the entire graph.
- Parameters
graph (kgx.graph.base_graph.BaseGraph) – The graph
name (str) – Name for the graph
node_facet_properties (Optional[List]) – A list of properties to facet on. For example,
['provided_by']
edge_facet_properties (Optional[List]) – A list of properties to facet on. For example,
['provided_by']
- Returns
The stats dictionary
- Return type
Dict
-
kgx.graph_operations.summarize_graph.
summarize_nodes
(graph: kgx.graph.base_graph.BaseGraph, facet_properties: Optional[List] = None) → Dict[source]¶ Summarize the nodes in a graph.
- Parameters
graph (kgx.graph.base_graph.BaseGraph) – The graph
facet_properties (Optional[List]) – A list of properties to facet on
- Returns
The node stats
- Return type
Dict