/** * Data structures for Penman graphs and triples. */ import { EpidataMap } from './epigraph'; import type { Attribute, Constant, Edge, Instance, Role, Triples, Variable } from './types'; export declare const CONCEPT_ROLE = ":instance"; export interface GraphOptions { /** The variable of the top node; if unspecified, the source of the first triple is used. */ top?: Variable | null; /** A mapping of triples to epigraphical markers. */ epidata?: EpidataMap; /** A mapping of metadata types to descriptions. */ metadata?: Record; } export interface GraphAttributesOptions { source?: Variable; role?: Role; target?: Constant; } export interface GraphEdgesOptions { source?: Variable; role?: Role; target?: Constant; } /** * Represents a basic class for modeling a rooted, directed acyclic graph. * * A `Graph` is defined by a list of triples, which can be divided into * two parts: a list of graph edges where both the source and target * are variables (node identifiers), and a list of node attributes * where only the source is a variable and the target is a constant. * The raw triples are available via the `triples` property, while the * `instances`, `edges`, and `attributes` methods return only those that * are concept relations, relations between nodes, or relations between * a node and a constant, respectively. * * @example * import { Graph } from 'penman-js'; * * const graph = new Graph([ * ['b', ':instance', 'bark-01'], * ['d', ':instance', 'dog'], * ['b', ':ARG0', 'd'] * ]); */ export declare class Graph { triples: Triples; private _id; private _top; epidata: EpidataMap; metadata: Record; /** * `options` consists of the following: * - `top`: The variable of the top node; if unspecified, the source of the first triple is used. * - `epidata`: A mapping of triples to epigraphical markers. * - `metadata`: A mapping of metadata types to descriptions. * * @param triples - An iterable of triples (either `Triple` objects or 3-tuples). * @param options - Optional arguments. * @param options.top - The variable of the top node; if unspecified, the source of the first triple is used. * @param options.epidata - A mapping of triples to epigraphical markers. * @param options.metadata - A mapping of metadata types to descriptions. */ constructor(triples?: Triples, options?: GraphOptions); /** @ignore */ __repr__(): string; /** Equivalent to `__repr__` in Python */ pprint(): string; toString(): string; /** * Return `true` if this graph is equal to other graph * * Equivalent to `__eq__` in Python */ equals(other: any): boolean; /** @ignore */ __or__(other: any): this; or(other: any): this; /** @ignore */ __ior__(other: any): this; ior(other: any): this; /** @ignore */ __sub__(other: any): this; sub(other: any): this; /** @ignore */ __isub__(other: any): this; isub(other: any): this; /** The top variable. */ get top(): Variable | null; set top(top: Variable | null); /** Return the set of variables (nonterminal node identifiers). */ variables(): Set; /** Return instances (concept triples). */ instances(): Instance[]; /** * Return edges filtered by their *source*, *role*, or *target*. * Edges don't include terminal triples (concepts or attributes). * * `options` consists of the following: * - `source`: The source variable to filter by. * - `role`: The role to filter by. * - `target`: The target variable to filter by. */ edges(options?: GraphEdgesOptions): Edge[]; /** * Return attributes filtered by their *source*, *role*, or *target*. * Attributes don't include concept triples or those where the * target is a nonterminal. * * `options` consists of the following: * - `source`: The source variable to filter by. * - `role`: The role to filter by. * - `target`: The target constant to filter by. */ attributes(options?: GraphAttributesOptions): Attribute[]; /** Filter triples based on their source, role, and/or target. */ private _filterTriples; /** * Return a mapping of variables to their re-entrancy count. * A re-entrancy is when more than one edge selects a node as its * target. These graphs are rooted, so the top node always has an * implicit entrancy. Only nodes with re-entrancies are reported, * and the count is only for the entrant edges beyond the first. * Also note that these counts are for the interpreted graph, not * for the linearized form, so inverted edges are always * re-entrant. */ reentrancies(): Map; }