decomp.graph.rdf

Module for converting NetworkX graphs to RDF format.

This module provides functionality to convert NetworkX DiGraph structures into RDFLib Graph objects, enabling semantic web queries and interoperability with RDF-based systems and tools.

Classes

RDFConverter

Converter class for transforming NetworkX digraphs into RDFLib graphs.

Notes

The conversion process handles node and edge attributes by mapping them to appropriate RDF triples. Special handling is provided for UDS-style annotations with value and confidence components.

class RDFConverter[source]

Bases: object

A converter between NetworkX digraphs and RDFLib graphs.

Parameters:

nxgraph (DiGraph) – the graph to convert

SUBSPACES: ClassVar[dict[str, URIRef]] = {}
PROPERTIES: ClassVar[dict[str, URIRef]] = {'confidence': rdflib.term.URIRef('confidence'), 'domain': rdflib.term.URIRef('domain'), 'subspace': rdflib.term.URIRef('subspace'), 'type': rdflib.term.URIRef('type')}
VALUES: ClassVar[dict[str, URIRef]] = {}
__init__(nxgraph)[source]
nodes: dict[str, URIRef]
classmethod networkx_to_rdf(nxgraph)[source]

Convert a NetworkX digraph to an RDFLib graph.

Parameters:

nxgraph (DiGraph) – the NetworkX graph to convert

Return type:

Graph