Options
All
  • Public
  • Public/Protected
  • All
Menu

Generic graph data structure that supports all types of vertex objects by using Maps. Allows you to associate arbitrary data with each edge. For vertex data, use an appropriate TVertex type.


// Type of the data we want to use as vertices.
interface Vertex {
  id: number;
  name: string;
  // ...
}

// Create a new graph.
const graph = GenericGraphAdapter.create<Vertex, string>();

// Add some vertices and edges.
const v1 = {id: 1, name: "foo"};
const v2 = {id: 2, name: "bar"};
const v3 = {id: 2, name: "bar"};

graph.addVertex(v1);
graph.addVertex(v2);
graph.addVertex(v3);

graph.addEdge(v1, v2, "This is edge 1-2.");
graph.addEdge(v2, v3, "This is edge 2-3.");

// Fetch the data associated with the edge.
graph.getEdgeData(v1, v2); // => "This is edge 1-2."

// This edge would create cycle.
graph.addEdge(v3, v1) // => false
graph.hasEdge(v3, v1) // => false
see

CommonAdapter

Type parameters

  • TVertex

    Type of the vertices of this graph.

  • TEdgeData

    Type of the data associated with edges.

Hierarchy

  • GenericGraphAdapter

Implements

Index

Methods

addEdge

  • addEdge(from: TVertex, to: TVertex, edgeData?: TEdgeData): boolean

addVertex

  • addVertex(vertex: TVertex): boolean

canAddEdge

  • canAddEdge(from: TVertex, to: TVertex): boolean

canContractEdge

  • canContractEdge(from: TVertex, to: TVertex): boolean

clone

  • clone(vertexCloner?: UnaryOperator<TVertex>, edgeDataCloner?: UnaryOperator<TEdgeData>): GenericGraphAdapter<TVertex, TEdgeData>

contractEdge

  • contractEdge(from: TVertex, to: TVertex, vertexMerger?: BinaryOperator<TVertex>, edgeMerger?: BinaryOperator<TEdgeData>): boolean

deleteEdge

  • deleteEdge(from: TVertex, to: TVertex): boolean

deleteVertex

  • deleteVertex(vertex: TVertex): boolean

getEdgeCount

  • getEdgeCount(): number

getEdgeData

  • getEdgeData(from: TVertex, to: TVertex): TEdgeData | undefined

getEdgeDataFrom

  • getEdgeDataFrom(vertex: TVertex): Iterator<TEdgeData>

getEdgeDataTo

  • getEdgeDataTo(vertex: TVertex): Iterator<TEdgeData>

getEdges

  • getEdges(): Iterator<Pair<TVertex>>

getEdgesWithData

  • getEdgesWithData(): Iterator<Triple<TVertex, TVertex, Maybe<TEdgeData>>>

getEdgesWithDataFrom

  • getEdgesWithDataFrom(vertex: TVertex): Iterator<Pair<TVertex, Maybe<TEdgeData>>>

getEdgesWithDataTo

  • getEdgesWithDataTo(vertex: TVertex): Iterator<Pair<TVertex, Maybe<TEdgeData>>>

getOrder

  • getOrder(vertex: TVertex): number

getPredecessorsOf

  • getPredecessorsOf(vertex: TVertex): Iterator<TVertex>

getSuccessorsOf

  • getSuccessorsOf(vertex: TVertex): Iterator<TVertex>

getVertexCount

  • getVertexCount(): number

getVertices

  • getVertices(): Iterator<TVertex>

hasEdge

  • hasEdge(from: TVertex, to: TVertex): boolean

hasVertex

  • hasVertex(vertex: TVertex): boolean

isReachable

  • isReachable(source: TVertex, target: TVertex): boolean

map

  • map<TClonedVertex, TClonedEdgeData>(vertexMapper: TypedFunction<TVertex, TClonedVertex>, edgeDataMapper: TypedFunction<TEdgeData, TClonedEdgeData>): GenericGraphAdapter<TClonedVertex, TClonedEdgeData>

setEdgeData

  • setEdgeData(from: TVertex, to: TVertex, data: TEdgeData | undefined): boolean

supportsOrder

  • supportsOrder(): boolean

Static create

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc