Skip to content

graph-data-structure/adjacency-list

Repository files navigation

Adjacency list code bricks for JavaScript. Follows the specification in @graph-data-structure/specification. Parent is @aureooms/js-gn.

⚠️ Depending on your environment, the code may require regeneratorRuntime to be defined, for instance by importing regenerator-runtime/runtime.

for ( let v of V( G ) ) ... ;

License Version Tests Dependencies GitHub issues Downloads

Code issues Code maintainability Code coverage (cov) Code technical debt Documentation Package size

Use

import {DoublyLinkedList as List} from '@list-abstraction/doubly-linked-list';
import {MultiGraph, MultiDiGraph} from '@graph-data-structure/adjacency-list';

let MultiGraph = MultiGraph( List ) ;
// use `MultiDiGraph( List , Map )` for directed multigraphs ;
// (`Map` is the new es6 class, or any other polyfill implementation)

let { V , E , N } = require( "@aureooms/js-graph-theory-notation" ) ;

let G = new Graph( ) ;

let u = G.vadd( ) ;

let v = G.vadd( ) ;

let e = G.eadd( u , v ) ;

for ( let w of V( G ) ) ... ;

for ( let e of E( G ) ) ... ;

for ( let w of N( G , u ) ) ... ;

G.edel( e ) ;

G.vdel( v ) ;

G.vdel( u ) ;