graphkit-js 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +19 -0
- package/README.md +93 -0
- package/dist/graphlib.core.js +1238 -0
- package/dist/graphlib.core.min.js +143 -0
- package/dist/graphlib.js +6905 -0
- package/dist/graphlib.min.js +2522 -0
- package/index.js +38 -0
- package/lib/alg/components.js +27 -0
- package/lib/alg/dfs.js +42 -0
- package/lib/alg/dijkstra-all.js +10 -0
- package/lib/alg/dijkstra.js +54 -0
- package/lib/alg/find-cycles.js +10 -0
- package/lib/alg/floyd-warshall.js +50 -0
- package/lib/alg/index.js +13 -0
- package/lib/alg/is-acyclic.js +15 -0
- package/lib/alg/postorder.js +7 -0
- package/lib/alg/preorder.js +7 -0
- package/lib/alg/prim.js +52 -0
- package/lib/alg/tarjan.js +47 -0
- package/lib/alg/topsort.js +35 -0
- package/lib/data/priority-queue.js +152 -0
- package/lib/graph.js +558 -0
- package/lib/index.js +5 -0
- package/lib/json.js +66 -0
- package/lib/lodash.js +34 -0
- package/lib/version.js +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2012-2014
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Graphkit
|
|
2
|
+
|
|
3
|
+
Graphkit-js is a lightweight JavaScript library that provides robust data structures for directed and undirected multigraphs, along with a collection of algorithms for working with them.
|
|
4
|
+
|
|
5
|
+
# Installation
|
|
6
|
+
|
|
7
|
+
## npm
|
|
8
|
+
|
|
9
|
+
Install via npm:
|
|
10
|
+
|
|
11
|
+
$ npm install graphkit-js
|
|
12
|
+
|
|
13
|
+
## Source Build
|
|
14
|
+
|
|
15
|
+
To build from source, ensure you have npm installed, then run from the project root:
|
|
16
|
+
|
|
17
|
+
$ make dist
|
|
18
|
+
|
|
19
|
+
# Example
|
|
20
|
+
|
|
21
|
+
The following example demonstrates basic usage in Node.js:
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
const { Graph } = require("graphkit-js");
|
|
25
|
+
|
|
26
|
+
// Create a new directed graph
|
|
27
|
+
const g = new Graph();
|
|
28
|
+
|
|
29
|
+
// Add node "a" with no label
|
|
30
|
+
g.setNode("a");
|
|
31
|
+
|
|
32
|
+
g.hasNode("a");
|
|
33
|
+
// => true
|
|
34
|
+
|
|
35
|
+
// Add node "b" with a string label
|
|
36
|
+
g.setNode("b", "b's value");
|
|
37
|
+
|
|
38
|
+
// Get the label for node "b"
|
|
39
|
+
g.node("b");
|
|
40
|
+
// => "b's value"
|
|
41
|
+
|
|
42
|
+
// Add node "c" with an object label
|
|
43
|
+
g.setNode("c", { k: 123 });
|
|
44
|
+
|
|
45
|
+
// List all nodes
|
|
46
|
+
g.nodes();
|
|
47
|
+
// => [ 'a', 'b', 'c' ]
|
|
48
|
+
|
|
49
|
+
// Add a directed edge from "a" to "b"
|
|
50
|
+
g.setEdge("a", "b");
|
|
51
|
+
|
|
52
|
+
// Add a directed edge with a label
|
|
53
|
+
// Node "d" is created automatically if it does not exist
|
|
54
|
+
g.setEdge("c", "d", { k: 456 });
|
|
55
|
+
|
|
56
|
+
// List all edges
|
|
57
|
+
g.edges();
|
|
58
|
+
// => [
|
|
59
|
+
// { v: 'a', w: 'b' },
|
|
60
|
+
// { v: 'c', w: 'd' }
|
|
61
|
+
// ]
|
|
62
|
+
|
|
63
|
+
// Edges leaving node "a"
|
|
64
|
+
g.outEdges("a");
|
|
65
|
+
// => [ { v: 'a', w: 'b' } ]
|
|
66
|
+
|
|
67
|
+
// Edges connected to node "d"
|
|
68
|
+
g.nodeEdges("d");
|
|
69
|
+
// => [ { v: 'c', w: 'd' } ]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
# API Reference
|
|
73
|
+
|
|
74
|
+
Full API documentation is available in the project Wiki.
|
|
75
|
+
|
|
76
|
+
# Bug Reports
|
|
77
|
+
|
|
78
|
+
Found a bug or have a feature request?
|
|
79
|
+
Please open an issue here:
|
|
80
|
+
|
|
81
|
+
👉 https://github.com/GRAPHKITORG/graphkit-js/issues
|
|
82
|
+
|
|
83
|
+
# Contributing
|
|
84
|
+
|
|
85
|
+
Contributions are welcome! Please submit pull requests or open issues to discuss proposed changes.
|
|
86
|
+
|
|
87
|
+
# License
|
|
88
|
+
|
|
89
|
+
Graphkit-js is licensed under the terms of the MIT License. See the
|
|
90
|
+
[LICENSE](LICENSE) file
|
|
91
|
+
for details.
|
|
92
|
+
|
|
93
|
+
[npm package manager]: http://npmjs.org/
|