decomp.corpus.corpus

Abstract base class for graph corpus readers.

This module provides the foundational Corpus class for managing collections of graphs in the decomp framework. The Corpus class serves as an abstract base that concrete corpus implementations extend to handle specific graph formats.

The module defines a generic corpus container that: - Accepts raw graphs in an input format - Transforms them to an output format via an abstract graph builder - Provides dictionary-like access to the processed graphs - Handles errors during graph construction gracefully

Type Variables

InGraph

The input graph type that will be processed by the corpus reader.

OutGraph

The output graph type produced after processing.

Type Aliases

GraphDict[T]

Generic dictionary mapping hashable identifiers to graphs of type T.

Classes

Corpus

Abstract base class for graph corpus containers with generic type parameters for input and output graph formats.

class Corpus[source]

Bases: Generic

Container for graphs.

Parameters:

graphs_raw (dict[Hashable, TypeVar(InGraph)]) – A sequence of graphs in a format that the graphbuilder for a subclass of this abstract class can process.

__init__(graphs_raw)[source]
items()[source]

Dictionary-like iterator for (graphid, graph) pairs.

Return type:

ItemsView[Hashable, TypeVar(OutGraph)]

property graphs: dict[Hashable, OutGraph]

The graphs in corpus.

property graphids: list[Hashable]

The graph ids in corpus.

property ngraphs: int

Number of graphs in corpus.

sample(k)[source]

Sample k graphs without replacement.

Parameters:

k (int) – the number of graphs to sample

Return type:

dict[Hashable, TypeVar(OutGraph)]