Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents a node in a graph. It consists of a unique id, a value and a collection of edges connecting it to other vertices.

Type parameters

  • T

Hierarchy

  • Vertex

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • new Vertex(id: string, value: T): Vertex
  • Returns a new Vertex with a unique id and associated value.

    Parameters

    • id: string

      Unique id in graph scope.

    • value: T

      The vertex value.

    Returns Vertex

Properties

Private _edges

_edges: Map<string, Edge>

A collection of edges stored in a Map for quick access and insert/remove operations.

id

id: string

Unique identifier in a graph scope. It should never be modified.

value

value: T

The vertex value.

Accessors

size

  • get size(): number
  • Returns number

Methods

addEdge

  • addEdge(edge: Edge): boolean
  • Adds a new edge to the collection.

    Parameters

    • edge: Edge

      The edge to add.

    Returns boolean

edges

  • Returns an array of the vertex edges.

    Returns Edge[]

forEachEdge

  • forEachEdge(callback: (edge: Edge, to: string) => void): void
  • Parameters

    • callback: (edge: Edge, to: string) => void
        • (edge: Edge, to: string): void
        • Parameters

          • edge: Edge
          • to: string

          Returns void

    Returns void

getEdge

  • getEdge(to: string): Edge | undefined
  • Parameters

    • to: string

    Returns Edge | undefined

hasEdge

  • hasEdge(to: string): boolean
  • Parameters

    • to: string

    Returns boolean

Private lock

  • lock(): void
  • Prevents from altering the vertex once created. Might change strategy later?

    Returns void

removeEdge

  • removeEdge(to: string): boolean
  • Parameters

    • to: string

    Returns boolean

Generated using TypeDoc