topologicpy.Kuzu module
- class topologicpy.Kuzu.Kuzu
Bases:
objectMethods
ByCSVPath(manager, path[, graphIDHeader, ...])Reads CSV graph data using TGraph.ByCSVPath when available, falling back to Graph.ByCSVPath, and upserts all returned graphs into Kuzu.
GraphByID(manager, graphID[, ontology, ...])Constructs a TopologicPy TGraph from Kuzu using the canonical graph id.
GraphsByOntologyClass(manager, ontologyClass)Returns TopologicPy Graphs or TGraphs whose stored graph ontology_class matches the input class.
GraphsByQuery(manager, query[, parameters, ...])Executes a Kuzu query and returns a list containing a TopologicPy TGraph constructed from the returned rows.
OntologyClasses(manager[, elementType, silent])Returns ontology class counts for graphs, vertices, edges, or all stored elements.
UpsertGraph(manager, graph[, graphIDKey, ...])Upserts a TopologicPy TGraph into Kuzu using the canonical GraphDB schema.
VerticesByOntologyClass(manager, ontologyClass)Returns stored vertex rows matching the input ontology class.
CandidateCountsForLabels
Connection
Database
DeleteGraph
EmptyDatabase
EnsureSchema
Execute
FetchAllPairs
FindBestExampleForLabel
ListGraphs
Manager
MaxNeighborsForLabel
Query
- static ByCSVPath(manager, path, graphIDHeader='graph_id', graphLabelHeader='label', graphFeaturesHeader='feat', graphFeaturesKeys=None, edgeSRCHeader='src_id', edgeDSTHeader='dst_id', edgeLabelHeader='label', edgeTrainMaskHeader='train_mask', edgeValidateMaskHeader='val_mask', edgeTestMaskHeader='test_mask', edgeFeaturesHeader='feat', edgeFeaturesKeys=None, nodeIDHeader='node_id', nodeLabelHeader='label', nodeTrainMaskHeader='train_mask', nodeValidateMaskHeader='val_mask', nodeTestMaskHeader='test_mask', nodeFeaturesHeader='feat', nodeXHeader='X', nodeYHeader='Y', nodeZHeader='Z', nodeFeaturesKeys=None, tolerance=0.0001, ontology: bool = True, silent=False)
Reads CSV graph data using TGraph.ByCSVPath when available, falling back to Graph.ByCSVPath, and upserts all returned graphs into Kuzu.
- static CandidateCountsForLabels(manager, labels, excludeLabels=None, limit: int = 50, silent: bool = False) list[dict]
- static Connection(manager, silent: bool = False)
- static Database(path: str, silent: bool = False)
- static DeleteGraph(manager, graphID: str, silent: bool = False) bool
- static EmptyDatabase(manager, dropSchema: bool = False, recreateSchema: bool = True, silent: bool = False) bool
- static EnsureSchema(manager, silent: bool = False) bool
- static Execute(manager, query: str, parameters: dict = None, write: bool = False, silent: bool = False)
- static FetchAllPairs(manager, undirected: bool = True, silent: bool = False) list[dict]
- static FindBestExampleForLabel(manager, label, attachTo=None, silent: bool = False)
- static GraphByID(manager, graphID: str, ontology: bool = True, asTGraph: bool = True, silent: bool = False)
Constructs a TopologicPy TGraph from Kuzu using the canonical graph id.
- Parameters
- managerKuzu manager
The input Kuzu manager.
- graphIDstr
The graph id to retrieve.
- ontologybool , optional
If True, ontology metadata is preserved/annotated where possible. Default is True.
- asTGraphbool , optional
Retained for call compatibility. Results are always TGraph. Default is True.
- silentbool , optional
If True, suppresses warnings/errors. Default is False.
- Returns
- topologicpy.TGraph
The reconstructed graph, or None.
- static GraphsByOntologyClass(manager, ontologyClass: str, ontology: bool = True, asTGraph: bool = True, silent: bool = False)
Returns TopologicPy Graphs or TGraphs whose stored graph ontology_class matches the input class.
- static GraphsByQuery(manager, query: str, parameters: dict = None, params: dict = None, ontology: bool = True, asTGraph: bool = True, silent: bool = False)
Executes a Kuzu query and returns a list containing a TopologicPy TGraph constructed from the returned rows. If rows return graph_id/gid only, full graphs are reconstructed using GraphByID.
- static ListGraphs(manager, where: dict = None, limit: int = 100, offset: int = 0, silent: bool = False) list[dict]
- static Manager(path: str, silent: bool = False)
- static MaxNeighborsForLabel(manager, label, silent: bool = False)
- static OntologyClasses(manager, elementType: str = 'all', silent: bool = False)
Returns ontology class counts for graphs, vertices, edges, or all stored elements.
- Parameters
- managerKuzu manager
The input Kuzu manager.
- elementTypestr , optional
One of “graph”, “vertex”, “edge”, or “all”. Default is “all”.
- silentbool , optional
If True, suppresses warning/error messages. Default is False.
- Returns
- list
A list of dictionaries with element_type, ontology_class, and count.
- static Query(manager, query: str, parameters: dict = None, silent: bool = False)
- static UpsertGraph(manager, graph, graphIDKey: str = 'id', vertexIDKey: str = 'id', vertexLabelKey: str = 'label', defaultVertexLabel: str = 'Node', vertexCategoryKey: str = 'category', defaultVertexCategory='Node', edgeLabelKey: str = 'label', defaultEdgeLabel: str = 'CONNECTED_TO', edgeCategoryKey: str = 'category', defaultEdgeCategory='Edge', bidirectional: bool = True, overwrite: bool = False, mantissa: int = 6, tolerance: float = 0.0001, database: str = None, ontology: bool = True, silent: bool = False) str
Upserts a TopologicPy TGraph into Kuzu using the canonical GraphDB schema.
The signature mirrors Neo4j.UpsertGraph. The database argument is accepted for GraphDB compatibility and ignored because Kuzu database identity is the manager/path. If ontology is True, the graph, vertices, and edges are annotated with TopologicPy ontology metadata before persistence.
- static VerticesByOntologyClass(manager, ontologyClass: str, graphID: str = None, silent: bool = False)
Returns stored vertex rows matching the input ontology class.
- Parameters
- managerKuzu manager
The input Kuzu manager.
- ontologyClassstr
The ontology class, for example “top:Room”.
- graphIDstr , optional
Optional graph id filter. Default is None.
- silentbool , optional
If True, suppresses warning/error messages. Default is False.
- Returns
- list
A list of vertex row dictionaries. The props value is decoded when possible.