def traverse_with_confidence( start_node_id: str, relation: str, min_confidence: float = 0.80, ) -> list[dict]: results = [] for path in graph.find_paths(start=start_node_id, edge_type=relation): identity_edges = [e for e in path.edges if e["relation"] == "SAME_AS"] if not identity_edges: results.append({"path": path, "path_confidence": 1.0}) continue worst_case = min(e["properties"]["match_probability"] for e in identity_edges) if worst_case >= min_confidence: results.append({"path": path, "path_confidence": worst_case}) return sorted(results, key=lambda x: x["path_confidence"], reverse=True)