Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DirectedGraph<T>

Type parameters

  • T

Hierarchy

  • DirectedGraph

Index

Constructors

constructor

  • Parameters

    • Default value vertexToString: function = x => String(x) + ''
        • (v: T): string
        • Parameters

          • v: T

          Returns string

    Returns DirectedGraph

Properties

Private edges

edges: Map<T, Set<T>> = new Map()

Private redges

redges: Map<T, Set<T>> = new Map()

Private Optional root

root: T

Private vertexToString

vertexToString: function

Type declaration

    • (v: T): string
    • Parameters

      • v: T

      Returns string

Private vertices

vertices: Map<T, VertexType> = new Map()

Methods

__computed

  • __computed(): string

addEdge

  • addEdge(fr: T, to: T): void

addVertex

checkCircular

  • checkCircular(u: T, path?: Set<T>, visited?: Set<T>): void
  • Parameters

    • u: T
    • Default value path: Set<T> = new Set()
    • Default value visited: Set<T> = new Set()

    Returns void

    如果存在返回一个 circuit,否则返回 null

findPathToRoot

  • findPathToRoot(vertex: T): T[]
  • Parameters

    • vertex: T

    Returns T[]

    从 vertex 到 root 的路径

getInVertices

  • getInVertices(u: T): IterableIterator<T>

getInVerticesRecursively

  • getInVerticesRecursively(target: T): Set<T>

getOutDegree

  • getOutDegree(u: T): number

getOutVerticies

  • getOutVerticies(u: T): IterableIterator<T>

hasEdge

  • hasEdge(fr: T, to: T): boolean
  • Parameters

    • fr: T
    • to: T

    Returns boolean

    包含返回 true 否则 false

preOrder

  • preOrder(vertex: T, visited?: Set<T>): IterableIterator<T>
  • Parameters

    • vertex: T
    • Default value visited: Set<T> = new Set()

    Returns IterableIterator<T>

toString

  • toString(): string

Private toTree

  • toTree(root?: undefined | T): object
  • Parameters

    • Default value root: undefined | T = this.root

    Returns object

    转为 Plain Object 的树状结构

    • [key: string]: Tree

Generated using TypeDoc