Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Graph<T>

Type parameters

  • T

Hierarchy

  • Graph

Implemented by

Index

Methods

addEdge

  • addEdge(from: string, to: string, weight: number): boolean
  • Adds an edge between two vertices with an optional weight. The order of from and to parameters only matters if the graph is directed. It fails if a vertex is not found or when trying to add an already existing edge.

    Parameters

    • from: string

      The origin vertex of the edge.

    • to: string

      The destination vertex of the edge.

    • weight: number

      The edge weight.

    Returns boolean

    true or false if insertion failed.

addVertex

  • addVertex(id: string, data?: any): boolean
  • Adds a new vertex, referenced with a unique id, holding given data. If the given id is already used, the insertion is aborted.

    Parameters

    • id: string

      The vertex ID. Must be unique

    • Optional data: any

      Additionnal data.

    Returns boolean

    true or false if it failed to insert.

get

  • get(id: string): Vertex<T> | undefined
  • Retrieves the vertex corresponding to given id.

    Parameters

    • id: string

      The vertex id.

    Returns Vertex<T> | undefined

    • The matching Vertex or undefined if not found.

getEdge

  • getEdge(from: string, to: string): Edge | undefined
  • Retrieves an edge connecting two vertices. The parameters order only matter in the case of a directed graph.

    Parameters

    • from: string
    • to: string

    Returns Edge | undefined

    The matched Vertex or undefined if not found

removeEdge

  • removeEdge(from: string, to: string): boolean
  • Removes the edge between two vertices. The order of from and to parameters only matters if the graph is directed. It fails if a vertex is not found or when trying to remove an inexistent edge.

    Parameters

    • from: string

      The origin vertex of the edge.

    • to: string

      The destination vertex of the edge.

    Returns boolean

    true or false if it failed to remove an edge.

removeVertex

  • removeVertex(id: string): boolean
  • Removes vertex qith given id and its related edges.

    Parameters

    • id: string

      id of the vertex to be removed.

    Returns boolean

    true or false if the vertex is not found.

Generated using TypeDoc