JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 84357
  • Score
    100M100P100Q182111F
  • License MIT

Shortest path functions for graphology.

Package Exports

  • graphology-shortest-path
  • graphology-shortest-path/unweighted

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (graphology-shortest-path) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build Status

Graphology Shortest Path

Shortest path functions for graphology.

Installation

npm install graphology-shortest-path

Usage

Unweighted

shortestPath

Returns the shortest path in the graph between source & target or null if such a path does not exist (same as bidirectional).

If you only pass the source & omit the target, will return a map of every shortest path between the source & all the nodes of the graph (same as singleSource).

import shortestPath from 'graphology-shortest-path';
// Alternatively, if you want to load only the relevant code
import shortestPath from 'graphology-shortest-path/unweighted';

// Returning the shortest path between source & target
const path = shortestPath(graph, source, target);

// Returning every shortest path between source & every node of the graph
const paths = shortestPath(graph, source);

Arguments

  • graph Graph: a graphology instance.
  • source any: source node.
  • [target] ?any: target node.

bidirectional

Returns the shortest path in the graph between source & target or null if such a path does not exist.

import {bidirectional} from 'graphology-shortest-path';
// Alternatively, if you want to load only the relevant code
import {bidirectional} from 'graphology-shortest-path/unweighted';

// Returning the shortest path between source & target
const path = bidirectional(graph, source, target);

Arguments

  • graph Graph: a graphology instance.
  • source any: source node.
  • target any: target node.

singleSource

Return a map of every shortest path between the given source & all the nodes of the graph.

import {singleSource} from 'graphology-shortest-path';
// Alternatively, if you want to load only the relevant code
import {singleSource} from 'graphology-shortest-path/unweighted';

// Returning every shortest path between source & every node of the graph
const paths = singleSource(graph, source);