Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Graph

Hierarchy

  • Graph

Index

Constructors

constructor

  • new Graph(totalVertices: number): Graph

Properties

connected

connected: boolean

Private counter

counter: number

directed

directed: boolean

edges

edges: Edge[]

level

level: number[]

simple

simple: boolean

totalVertices

totalVertices: number

vertices

vertices: Vertex[]

Methods

addEdge

  • addEdge(edge: Edge): void

addVertex

  • addVertex(vertex: Vertex): void

calcFlow

  • calcFlow(start: number, end: number, targetFlow: number, count: number[]): number
  • Depth First Search-like: send flow at along path from from->to recursively while increasing the level of the visited vertices by one

    Parameters

    • start: number

      the vertex to start at

    • end: number

      the vertex to try and reach

    • targetFlow: number

      the amount of flow to try and achieve

    • count: number[]

      keep track of which vertices have been visited so we don't include them twice

    Returns number

calcMinCut

  • calcMinCut(source: number, sink: number): number
  • Calculates min-cut graph using Dinic's Algorithm. use getMinCut to get the actual verticies in the minCut

    Parameters

    • source: number

      Source vertex

    • sink: number

      Sink vertex

    Returns number

connect

  • connect(vertex1: Vertex, vertex2: Vertex, weight?: undefined | number, directional?: undefined | false | true): void
  • Parameters

    • vertex1: Vertex
    • vertex2: Vertex
    • Optional weight: undefined | number
    • Optional directional: undefined | false | true

    Returns void

createLevelGraph

  • createLevelGraph(from: number, to: number): boolean
  • Uses Breadth First Search to see if a path exists to the vertex 'to' and generate the level graph

    Parameters

    • from: number

      vertex to start from

    • to: number

      vertex to try and reach

    Returns boolean

disconnect

getMinCut

  • getMinCut(from: number): number[]
  • Uses Breadth First Search to find the vertices in the minCut for the graph

    • Must call calcMinCut first to prepare the graph

    Parameters

    • from: number

      the vertex to start from

    Returns number[]

newEdge

  • newEdge(from: number, to: number, capacity: number): void
  • Create a new edge in the graph as well as a corresponding reverse edge on the residual graph

    Parameters

    • from: number

      vertex edge starts at

    • to: number

      vertex edge leads to

    • capacity: number

      max flow capacity for this edge

    Returns void

removeEdge

  • removeEdge(edge: Edge): void

removeVertex

  • removeVertex(vertex: Vertex): void

Generated using TypeDoc