Skip to main content

DirectedGraph <T>

A class representing a directed graph. The graph consists of string nodes, and edges defined by string to/from 2-tuples

Index

Constructors

constructor

Properties

adjacencyList

adjacencyList: Record<string, string[]>

edges

edges: [T, T][]

size

size: number

vertices

vertices: T[]

Methods

buildAdjacencyList

  • buildAdjacencyList(): Record<string, string[]>
  • Constructs and sets the adjacency list for this graph based on its edge definitions


    Returns Record<string, string[]>

    • The adjacency list for the graph

findCycles

  • findCycles(): T[][]

getStronglyConnectedComponents

  • getStronglyConnectedComponents(): T[][]

removeVertex

  • Creates a new subgraph of this graph by removing a given vertex, along with all edges attached to that vertex


    Parameters

    • vertex: T

      The vertex to remove

    Returns DirectedGraph<T>

    • The subgraph of this graph obtained by removing the given vertex and all attached edges

subgraphFromVertices

  • Creates a new subgraph of this graph by keeping only the given vertices and any edges between them


    Parameters

    • vertices: T[]

      The vertices to keep

    Returns DirectedGraph<T>

    • The subgraph of this graph obtained by only keeping the given vertices and any edges between them