MCPcopy Create free account
hub / github.com/InternScience/InternAgent / get_graph_stats

Method get_graph_stats

internagent/mas/memory/long_memory.py:367–381  ·  view source on GitHub ↗

Get statistics about the idea graph. Returns: Dict containing graph statistics

(self)

Source from the content-addressed store, hash-verified

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
384class PromptEvolver:

Callers 2

generate_ideasMethod · 0.80

Calls 2

is_connectedMethod · 0.80
valuesMethod · 0.45

Tested by

no test coverage detected