Get statistics about the idea graph. Returns: Dict containing graph statistics
(self)
| 365 | return ((node, self.graph.nodes[node].get('cluster_id', 0)) for node in self.graph.nodes) |
| 366 | |
| 367 | def get_graph_stats(self) -> Dict[str, Any]: |
| 368 | """ |
| 369 | Get statistics about the idea graph. |
| 370 | |
| 371 | Returns: |
| 372 | Dict containing graph statistics |
| 373 | """ |
| 374 | return { |
| 375 | "num_nodes": len(self.graph.nodes), |
| 376 | "num_edges": len(self.graph.edges), |
| 377 | "density": nx.density(self.graph) if len(self.graph.nodes) > 0 else 0, |
| 378 | "is_connected": nx.is_connected(self.graph) if len(self.graph.nodes) > 0 else False, |
| 379 | "num_components": nx.number_connected_components(self.graph) if len(self.graph.nodes) > 0 else 0, |
| 380 | "avg_degree": sum(dict(self.graph.degree()).values()) / len(self.graph.nodes) if len(self.graph.nodes) > 0 else 0 |
| 381 | } |
| 382 | |
| 383 | |
| 384 | class PromptEvolver: |
no test coverage detected