Options
All
  • Public
  • Public/Protected
  • All
Menu

The Digraph class represents a directed graph of vertices. It supports adding new vertices and edges, iteration over all vertices and iteration over all of the vertices adjecent from a given vertex. Parallel edges and self-loops are permitted.

Type parameters

  • V

Hierarchy

  • Digraph

Implemented by

Index

Methods

addEdge

  • Adds the directed edge 'from -> to' to the digraph. If any of the vertices in the edge is not in the digraph, the method adds the vertex.

    Parameters

    • from: Vertex<V>

      the tail vertex.

    • to: Vertex<V>

      the head vertex.

    Returns Digraph<V>

    digraph with the added edge.

addVertex

  • Adds new vertext to the digraph. If digraph already has vertex with the same key, it doesn't add new one.

    Parameters

    Returns Digraph<V>

    digraph with the added vertex.

adjacent

  • Returns the vertices adjacent from given vertex in the digraph. If there is no such vertex in the digraph, the method returns empty container.

    Parameters

    Returns Collection<Vertex<V>>

    the vertices adjacent from given vertex in the digraph or empty container.

asEdgesCollection

asVerticesCollection

  • Returns collection backed by vertices of this graph. Time complexity is O(1).

    Returns Collection<Vertex<V>>

    collection of vertices.

e

  • e(): number
  • Returns the number of edges in the digraph.

    Returns number

    the number of edges in the digraph.

indegree

  • indegree(v: Vertex<V>): number
  • Returns the number of directed edges incident to vertex v. This is known as the

    indegree of vertex v.

    Parameters

    Returns number

    the indegree of vertex v or 0 if there is no such vertex in the graph.

outdegree

  • outdegree(v: Vertex<V>): number
  • Returns the number of directed edges incident from vertex v. This is known as the

    outdegree of vertex v.

    Parameters

    Returns number

    the outdegree of vertex v or 0 if there is no such vertex in the graph.

reverse

toString

  • toString(): string
  • Returns a string representation of the graph. This method takes time proportional to E + V.

    Returns string

    the number of vertices V, followed by the number of edges E, followed by the

    V adjacency lists

v

  • v(): number
  • Returns the number of vertices in the digraph.

    Returns number

    the number of vertices in the digraph.

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