Is there any JavaScript libraries for graph operations and algorithms?

后端 未结 6 1584
北恋
北恋 2020-12-28 15:36

What I need is a JavaScript implementation of pure mathematical graphs. To be clear I DON\'T mean graph visualization libraries like sigma.js or d3.js.

The library I

6条回答
  •  天命终不由人
    2020-12-28 16:20

    Now there is a library: graphlib

    Graphlib is a JavaScript library that provides data structures for undirected and directed multi-graphs along with algorithms that can be used with them.

    Implements:

    • directed and undirected graphs (does A -> B imply B -> A)
    • multigraphs (multiple distinct named edges from A -> B)
    • compound graphs (nodes can have children that form a "subgraph")
    • Dijkstra algorithm (shortest path)
    • Floyd-Warshall algorithm (shortest path supporting negative weights)
    • Prim's algorithm (minimum spanning tree)
    • Tarjan's algorithm (strongly connected components)
    • Topological sorting (dependency sort for directed acyclic graphs)
    • Pre- and postorder traversal (callback on every node)
    • Finding all cycles and testing if a graph is acyclic
    • Finding all connected components

    NPM, Bower and browser supported, MIT license.

提交回复
热议问题