forked from dagrejs/graphlib
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
1,476 additions
and
1,257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"presets": [ | ||
["@babel/preset-env", { "targets": { "node": "current" } }], | ||
"@babel/preset-typescript" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/node_modules | ||
/.vscode | ||
.idea/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"arrowParens": "always", | ||
"trailingComma": "all", | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
var dijkstra = require("./dijkstra"); | ||
var _ = require("../lodash"); | ||
var dijkstra = require('./dijkstra'); | ||
var _ = require('../lodash'); | ||
|
||
module.exports = dijkstraAll; | ||
|
||
function dijkstraAll(g, weightFunc, edgeFunc) { | ||
return _.transform(g.nodes(), function(acc, v) { | ||
acc[v] = dijkstra(g, v, weightFunc, edgeFunc); | ||
}, {}); | ||
return _.transform( | ||
g.nodes(), | ||
function (acc, v) { | ||
acc[v] = dijkstra(g, v, weightFunc, edgeFunc); | ||
}, | ||
{}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
var _ = require("../lodash"); | ||
var tarjan = require("./tarjan"); | ||
var _ = require('../lodash'); | ||
var tarjan = require('./tarjan'); | ||
|
||
module.exports = findCycles; | ||
|
||
function findCycles(g) { | ||
return _.filter(tarjan(g), function(cmpt) { | ||
return cmpt.length > 1 || (cmpt.length === 1 && g.hasEdge(cmpt[0], cmpt[0])); | ||
return _.filter(tarjan(g), function (cmpt) { | ||
return ( | ||
cmpt.length > 1 || (cmpt.length === 1 && g.hasEdge(cmpt[0], cmpt[0])) | ||
); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
module.exports = { | ||
components: require("./components"), | ||
dijkstra: require("./dijkstra"), | ||
dijkstraAll: require("./dijkstra-all"), | ||
findCycles: require("./find-cycles"), | ||
floydWarshall: require("./floyd-warshall"), | ||
isAcyclic: require("./is-acyclic"), | ||
postorder: require("./postorder"), | ||
preorder: require("./preorder"), | ||
prim: require("./prim"), | ||
tarjan: require("./tarjan"), | ||
topsort: require("./topsort") | ||
components: require('./components'), | ||
dijkstra: require('./dijkstra'), | ||
dijkstraAll: require('./dijkstra-all'), | ||
findCycles: require('./find-cycles'), | ||
floydWarshall: require('./floyd-warshall'), | ||
isAcyclic: require('./is-acyclic'), | ||
postorder: require('./postorder'), | ||
preorder: require('./preorder'), | ||
prim: require('./prim'), | ||
tarjan: require('./tarjan'), | ||
topsort: require('./topsort'), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
var topsort = require("./topsort"); | ||
var topsort = require('./topsort'); | ||
|
||
module.exports = isAcyclic; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
var dfs = require("./dfs"); | ||
var dfs = require('./dfs'); | ||
|
||
module.exports = postorder; | ||
|
||
function postorder(g, vs) { | ||
return dfs(g, vs, "post"); | ||
return dfs(g, vs, 'post'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
var dfs = require("./dfs"); | ||
var dfs = require('./dfs'); | ||
|
||
module.exports = preorder; | ||
|
||
function preorder(g, vs) { | ||
return dfs(g, vs, "pre"); | ||
return dfs(g, vs, 'pre'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.