KnowledgeGraph.compose()

Merge another graph into this one.

Usage

Source

KnowledgeGraph.compose(
    other, *, namespace="", merge_strategy="additive", conflict="keep_local"
)

Parameters

other: ‘KnowledgeGraph’

The source graph to merge from.

namespace: str = ""

If non-empty, node IDs from other are prefixed with namespace: to avoid collisions.

merge_strategy: str = "additive"

"additive" (default) — add new nodes/edges without removing existing ones.

conflict: str = "keep_local"
How to handle ID collisions: "keep_local" (default) skips duplicates, "keep_remote" overwrites with the incoming node.

Returns

int
Number of nodes added or updated.