src.dackar.knowledge_graph.kg_query_utils¶
Functions¶
|
Return True if component_a is upstream of component_b in the graph. |
|
Classify the relationship path between two components. |
Module Contents¶
- src.dackar.knowledge_graph.kg_query_utils.is_upstream(component_a, component_b, neo4j_client, database=None)[source]¶
Return True if component_a is upstream of component_b in the graph.
Walks up to six containment/connectivity hops (
has_part_usage,owns_port_usage,connects_port) fromcomponent_atowardcomponent_boverelement_usagenodes.- Parameters:
component_a (Optional[str]) – Source component id (
element_usage.id). A falsy value, orcomponent_a == component_b, yieldsFalse.component_b (Optional[str]) – Target component id (
element_usage.id).neo4j_client (Optional[Any]) – Object exposing
query(cypher, params, db=...); whenNonethe function returnsFalsewithout querying.database (Optional[str]) – Optional Neo4j database name;
Noneuses the client default.
- Returns:
Trueif a directed patha -> ... -> bexists, otherwiseFalse. Any query error is swallowed and reported asFalse.- Return type:
bool
- src.dackar.knowledge_graph.kg_query_utils.resolve_edge_type(component_a, component_b, neo4j_client, database=None)[source]¶
Classify the relationship path between two components.
Inspects the relationship types along the (up to six-hop) path from
component_atocomponent_band buckets them into a single category.- Parameters:
component_a (Optional[str]) – Source component id (
element_usage.id). A falsy value yields"mixed".component_b (Optional[str]) – Target component id (
element_usage.id).neo4j_client (Optional[Any]) – Object exposing
query(cypher, params, db=...); whenNonethe function returns"mixed"without querying.database (Optional[str]) – Optional Neo4j database name;
Noneuses the client default.
- Returns:
"containment"if the path uses onlyhas_part_usageedges,"connectivity"if it uses onlyowns_port_usage/connects_portedges, otherwise"mixed"(also returned when no path is found or a query error occurs).- Return type:
str