Graph Generator

Documentation

class pandasaurus.graph.graph_generator.GraphGenerator[source]
static apply_transitive_reduction(graph: Graph, predicate_list: List[str]) Graph[source]

Applies transitive reduction to a given RDF graph using specified predicates.

Parameters:
  • graph (Graph) – The RDF graph to which transitive reduction is applied.

  • predicate_list (List[str]) – A list of predicates (URIs or ‘rdfs:subClassOf’) to which transitive reduction will be applied.

Returns:

The RDF graph after applying transitive reduction to the specified predicates.

Return type:

Graph

Note

  • The method applies transitive reduction to the specified predicates by adding only the necessary edges to create a directed acyclic graph.

  • Redundant triples are removed from the graph using transitive reduction results.

  • The ‘predicate_list’ should contain valid predicates existing in the graph.

  • For ‘predicate_list’, you can use either full URIs or ‘rdfs:subClassOf’ for the RDF schema ‘subClassOf’ relationship.

static generate_enrichment_graph(enriched_df: DataFrame) Graph[source]

Generates an RDF graph representing enrichment relationships from an enriched DataFrame.

Parameters:

enriched_df (pd.DataFrame) – A DataFrame containing enrichment relationships. It should have columns ‘s’, ‘s_label’, ‘o’, and ‘o_label’ representing subjects, subject labels, objects, and object labels respectively.

Returns:

An RDF graph representing the enrichment relationships.

Each subject is linked to its corresponding object using the ‘subClassOf’ relationship, and labels are associated with subjects and objects using the ‘label’ relationship.

Return type:

Graph