/*! * Copyright 2020 Ron Buckton * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import type { GraphNode } from "./graphNode"; import type { GraphSchema } from "./graphSchema"; import type { Graph } from "./graph"; import { GraphObject } from "./graphObject"; /** * Represents a link between two nodes in the graph. */ export declare class GraphLink extends GraphObject { private _source; private _target; private _index; private constructor(); /** * Gets the graph that this object belongs to. */ get owner(): Graph; /** * Gets the document schema for this object. */ get schema(): GraphSchema; /** * The source of the link. */ get source(): GraphNode; /** * The target of the link. */ get target(): GraphNode; /** * An optional index for the link (default `0`). */ get index(): number; /** * Gets a value indicating whether this is a containment link. */ get isContainment(): boolean; /** * Gets or sets a descriptive label to associate with this link. */ get label(): string | undefined; set label(label: string | undefined); /** * Creates an iterator for the links related to this link. * @param searchDirection Either `"source"` to find related links across the incoming links of sources, or `"target"` to find related links across the outgoing links of targets. * @param traversal An object that specifies callbacks used to control how links are traversed and which links are yielded during iteration. */ related(searchDirection: "source" | "target", traversal?: GraphLinkTraversal): IterableIterator; /** * Removes this link from the graph. */ deleteSelf(): boolean; } export interface GraphLinkTraversal { /** * A callback used to determine whether a link should be traversed. If not specified, all links are traversed. */ traverseLink?: (this: void, link: GraphLink) => boolean; /** * A callback used to determine whether a link should be yielded. If not specified, all links are yielded. */ acceptLink?: (this: void, link: GraphLink) => boolean; }