graphs-for-js
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -1,6 +0,6 @@ | ||
import { WeightedUndirectedGraph } from './src/WeightedUndirectedGraph'; | ||
import { UndirectedGraph } from './src/UndirectedGraph'; | ||
import { WeightedDirectedGraph } from './src/WeightedDirectedGraph'; | ||
import { DirectedGraph } from './src/DirectedGraph'; | ||
import * as GraphUtility from './src/GraphUtil'; | ||
import { ReadonlyDirectedGraph, ReadonlyWeightedDirectedGraph } from './src/readonly/ImmutableDirectedGraphs'; | ||
import { ReadonlyUndirectedGraph, ReadonlyWeightedUndirectedGraph } from './src/readonly/ImmutableUndirectedGraphs'; | ||
import { DirectedGraph, WeightedDirectedGraph } from './src/mutable/DirectedGraphs'; | ||
import { UndirectedGraph, WeightedUndirectedGraph } from './src/mutable/UndirectedGraphs'; | ||
/** | ||
@@ -13,2 +13,12 @@ * A builder tool for constructing graph data structures. Returns to callback functions, | ||
withKeyFunction: (fn: (v: V) => string) => { | ||
readonly: (nodes: V[]) => { | ||
directed: { | ||
weighted: (edges: [V, V, E][]) => ReadonlyWeightedDirectedGraph<V, E>; | ||
unweighted: (edges: [V, V][]) => ReadonlyDirectedGraph<V, E>; | ||
}; | ||
undirected: { | ||
weighted: (edges: [V, V, E][]) => ReadonlyWeightedUndirectedGraph<V, E>; | ||
unweighted: (edges: [V, V][]) => ReadonlyUndirectedGraph<V, E>; | ||
}; | ||
}; | ||
directed: { | ||
@@ -24,2 +34,12 @@ weighted: () => WeightedDirectedGraph<V, E>; | ||
withoutKeyFunction: () => { | ||
readonly: (nodes: V[]) => { | ||
directed: { | ||
weighted: (edges: [V, V, E][]) => ReadonlyWeightedDirectedGraph<V, E>; | ||
unweighted: (edges: [V, V][]) => ReadonlyDirectedGraph<V, E>; | ||
}; | ||
undirected: { | ||
weighted: (edges: [V, V, E][]) => ReadonlyWeightedUndirectedGraph<V, E>; | ||
unweighted: (edges: [V, V][]) => ReadonlyUndirectedGraph<V, E>; | ||
}; | ||
}; | ||
directed: { | ||
@@ -40,2 +60,3 @@ weighted: () => WeightedDirectedGraph<V, E>; | ||
export declare const GraphUtil: typeof GraphUtility; | ||
export { GraphType } from './src/types/GraphType'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -22,17 +22,37 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GraphUtil = exports.GraphBuilder = void 0; | ||
var WeightedUndirectedGraph_1 = require("./src/WeightedUndirectedGraph"); | ||
var UndirectedGraph_1 = require("./src/UndirectedGraph"); | ||
var WeightedDirectedGraph_1 = require("./src/WeightedDirectedGraph"); | ||
var DirectedGraph_1 = require("./src/DirectedGraph"); | ||
exports.GraphType = exports.GraphUtil = exports.GraphBuilder = void 0; | ||
var GraphUtility = __importStar(require("./src/GraphUtil")); | ||
var ImmutableDirectedGraphs_1 = require("./src/readonly/ImmutableDirectedGraphs"); | ||
var ImmutableUndirectedGraphs_1 = require("./src/readonly/ImmutableUndirectedGraphs"); | ||
var DirectedGraphs_1 = require("./src/mutable/DirectedGraphs"); | ||
var UndirectedGraphs_1 = require("./src/mutable/UndirectedGraphs"); | ||
var builder = function (fn) { | ||
return { | ||
readonly: function (nodes) { | ||
return { | ||
directed: { | ||
weighted: function (edges) { | ||
return new ImmutableDirectedGraphs_1.ReadonlyWeightedDirectedGraph(nodes, edges, fn); | ||
}, | ||
unweighted: function (edges) { | ||
return new ImmutableDirectedGraphs_1.ReadonlyDirectedGraph(nodes, edges, fn); | ||
} | ||
}, | ||
undirected: { | ||
weighted: function (edges) { | ||
return new ImmutableUndirectedGraphs_1.ReadonlyWeightedUndirectedGraph(nodes, edges, fn); | ||
}, | ||
unweighted: function (edges) { | ||
return new ImmutableUndirectedGraphs_1.ReadonlyUndirectedGraph(nodes, edges, fn); | ||
} | ||
} | ||
}; | ||
}, | ||
directed: { | ||
weighted: function () { return new WeightedDirectedGraph_1.WeightedDirectedGraph(fn); }, | ||
unweighted: function () { return new DirectedGraph_1.DirectedGraph(fn); } | ||
weighted: function () { return new DirectedGraphs_1.WeightedDirectedGraph(fn); }, | ||
unweighted: function () { return new DirectedGraphs_1.DirectedGraph(fn); } | ||
}, | ||
undirected: { | ||
weighted: function () { return new WeightedUndirectedGraph_1.WeightedUndirectedGraph(fn); }, | ||
unweighted: function () { return new UndirectedGraph_1.UndirectedGraph(fn); } | ||
weighted: function () { return new UndirectedGraphs_1.WeightedUndirectedGraph(fn); }, | ||
unweighted: function () { return new UndirectedGraphs_1.UndirectedGraph(fn); } | ||
} | ||
@@ -61,2 +81,4 @@ }; | ||
exports.GraphUtil = GraphUtility; | ||
var GraphType_1 = require("./src/types/GraphType"); | ||
Object.defineProperty(exports, "GraphType", { enumerable: true, get: function () { return GraphType_1.GraphType; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,3 @@ | ||
export declare const hasCycle: <V>(graph: import("./types/GraphInterface").GraphInterface<V, unknown>) => boolean; | ||
export declare const findShortestPath: <V, E>(graph: import("./types/GraphInterface").GraphInterface<V, E>, start: V, end: V) => { | ||
export declare const hasCycle: <V>(graph: import("./types/GraphInterface").IReadonlyGeneralNodeGraph<V, unknown>) => boolean; | ||
export declare const findShortestPath: <V, E>(graph: import("./types/GraphInterface").IReadonlyGeneralNodeGraph<V, E>, start: V, end: V) => { | ||
path: V[]; | ||
@@ -7,19 +7,36 @@ pathSize: number; | ||
export declare const json: { | ||
stringify: <V, E>(graph: import("./types/GraphInterface").GraphInterface<V, E>) => string; | ||
parse: <V_1, E_1 = unknown>(jsonString: string, keyFunction?: ((v: V_1) => string) | undefined) => import("./types/GraphInterface").GraphInterface<V_1, E_1> | undefined; | ||
stringify: <V, E>(graph: import("./types/GraphInterface").IReadonlyGeneralNodeGraph<V, E>) => string; | ||
parse: <V_1, E_1 = unknown>(jsonString: string, keyFunction?: ((v: V_1) => string) | undefined) => import("./types/GraphInterface").IGeneralNodeGraph<V_1, E_1> | undefined; | ||
}; | ||
export declare const castGraph: <V, E>(g: import("./types/GraphInterface").GraphInterface<V, E>) => { | ||
type: import("./types/GraphType").GraphType.WeightedDirected; | ||
graph: import("./WeightedDirectedGraph").WeightedDirectedGraph<V, E>; | ||
export declare const castGraph: <V, E>(g: import("./types/GraphInterface").IReadonlyGeneralNodeGraph<V, E>) => { | ||
type: import("..").GraphType.WeightedDirected; | ||
graph: import("./mutable/DirectedGraphs").WeightedDirectedGraph<V, E>; | ||
} | { | ||
type: import("./types/GraphType").GraphType.NonWeightedDirected; | ||
graph: import("./DirectedGraph").DirectedGraph<V, E>; | ||
type: import("..").GraphType.NonWeightedDirected; | ||
graph: import("./mutable/DirectedGraphs").DirectedGraph<V, E>; | ||
} | { | ||
type: import("./types/GraphType").GraphType.WeightedUndirected; | ||
graph: import("./WeightedUndirectedGraph").WeightedUndirectedGraph<V, E>; | ||
type: import("..").GraphType.WeightedUndirected; | ||
graph: import("./mutable/UndirectedGraphs").WeightedUndirectedGraph<V, E>; | ||
} | { | ||
type: import("./types/GraphType").GraphType.NonWeightedUndirected; | ||
graph: import("./UndirectedGraph").UndirectedGraph<V, E>; | ||
type: import("..").GraphType.NonWeightedUndirected; | ||
graph: import("./mutable/UndirectedGraphs").UndirectedGraph<V, E>; | ||
} | { | ||
type: import("..").GraphType.ReadonlyWeightedUndirected; | ||
graph: import("./readonly/ImmutableUndirectedGraphs").ReadonlyWeightedUndirectedGraph<V, E>; | ||
} | { | ||
type: import("..").GraphType.ReadonlyWeightedDirected; | ||
graph: import("./readonly/ImmutableDirectedGraphs").ReadonlyWeightedDirectedGraph<V, E>; | ||
} | { | ||
type: import("..").GraphType.ReadonlyNonWeightedDirected; | ||
graph: import("./readonly/ImmutableDirectedGraphs").ReadonlyDirectedGraph<V, E>; | ||
} | { | ||
type: import("..").GraphType.ReadonlyNonWeightedUndirected; | ||
graph: import("./readonly/ImmutableUndirectedGraphs").ReadonlyUndirectedGraph<V, E>; | ||
}; | ||
export declare const clone: <V, E>(g: import("./types/GraphInterface").GraphInterface<V, E>) => import("./types/GraphInterface").GraphInterface<V, E>; | ||
export declare const clone: <V, E>(g: import("./types/GraphInterface").IReadonlyGeneralNodeGraph<V, E>) => import("./types/GraphInterface").IGeneralNodeGraph<V, E>; | ||
export declare const functional: { | ||
subset: <V, E>(g: import("./types/GraphInterface").IReadonlyGeneralNodeGraph<V, E>, nodes: V[]) => import("./types/GraphInterface").IGeneralNodeGraph<V, E>; | ||
mapEdges: <V_1, E_1, R>(g: import("./types/GraphInterface").IReadonlyWeightedGraph<V_1, E_1>, callback: (e: E_1) => R) => import("./types/GraphInterface").IGeneralNodeGraph<V_1, R>; | ||
mapNodes: <V_2, E_2, N>(g: import("./types/GraphInterface").IReadonlyGeneralNodeGraph<V_2, E_2>, callback: (v: V_2) => N, newKeyFunction?: ((n: N) => string) | undefined) => import("./types/GraphInterface").IGeneralNodeGraph<N, E_2>; | ||
}; | ||
//# sourceMappingURL=GraphUtil.d.ts.map |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
@@ -22,3 +33,3 @@ if (k2 === undefined) k2 = k; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.clone = exports.castGraph = exports.json = exports.findShortestPath = exports.hasCycle = void 0; | ||
exports.functional = exports.clone = exports.castGraph = exports.json = exports.findShortestPath = exports.hasCycle = void 0; | ||
var HasCycle = __importStar(require("./util/HasCycle")); | ||
@@ -29,2 +40,3 @@ var FindShortestPath = __importStar(require("./util/FindShortestPath")); | ||
var cloner = __importStar(require("./util/GraphClone")); | ||
var functionalFn = __importStar(require("./util/functional")); | ||
exports.hasCycle = HasCycle.hasCycle; | ||
@@ -38,2 +50,3 @@ exports.findShortestPath = FindShortestPath.findShortestPath; | ||
exports.clone = cloner.clone; | ||
exports.functional = __assign({}, functionalFn); | ||
//# sourceMappingURL=GraphUtil.js.map |
@@ -11,3 +11,3 @@ import { GraphType } from './GraphType'; | ||
} | ||
export interface GraphInterface<V, E = unknown> { | ||
export interface IReadonlyGeneralNodeGraph<V, E = unknown> { | ||
/** | ||
@@ -33,14 +33,2 @@ * The given Key Function used by the graph to determine the identity and uniqueness | ||
/** | ||
* Add nodes to the graph. | ||
* Return the number of nodes added. | ||
* @param nodes | ||
*/ | ||
insert: (...nodes: V[]) => number; | ||
/** | ||
* Remove nodes from the graph. | ||
* Return the number of nodes removed. | ||
* @param nodes | ||
*/ | ||
remove: (...nodes: V[]) => number; | ||
/** | ||
* Returns true if all of the given nodes are in the graph. | ||
@@ -93,9 +81,2 @@ * @param nodes | ||
/** | ||
* Create an edge from the source node to the target node. Return true if a new | ||
* edge is created, otherwise false. | ||
* @param source | ||
* @param target | ||
*/ | ||
connect: (source: V, target: V, value?: any) => boolean; | ||
/** | ||
* Return true if an edge from source to the target exists in the graph, | ||
@@ -107,20 +88,5 @@ * otherwise false. | ||
hasEdge: (source: V, target: V, value?: any) => boolean; | ||
/** | ||
* Remove the edge from source to target. | ||
* Return true if an edge is removed, otherwise false. | ||
* @param source | ||
* @param target | ||
*/ | ||
disconnect: (source: V, target: V, value?: any) => boolean; | ||
} | ||
export interface ValueGraph<V, E> extends GraphInterface<V, E> { | ||
export interface IReadonlyWeightedGraph<V, E> extends IReadonlyGeneralNodeGraph<V, E> { | ||
/** | ||
* Create an edge from the source node to the target node with a given weight value. | ||
* Return true if the edges in the graph changes, i.e. a new edge is created | ||
* or an edge has its value changed. Return false otherwise. | ||
* @param source | ||
* @param target | ||
*/ | ||
connect: (source: V, target: V, value: E) => boolean; | ||
/** | ||
* Return true if edge from source to target exists, otherwise false. | ||
@@ -134,13 +100,2 @@ * If value is given, then the value of the edge in the graph must also equal | ||
/** | ||
* Remove the edge from source to target. | ||
* Return true if an edge is removed, otherwise false. | ||
* | ||
* If a value is given, then the value of the edge in the graph must also equal | ||
* the given value to be removed. | ||
* | ||
* @param source | ||
* @param target | ||
*/ | ||
disconnect: (source: V, target: V, value?: E) => boolean; | ||
/** | ||
* Return an array of all incoming edges into the given node. | ||
@@ -164,2 +119,51 @@ * @param node | ||
} | ||
export interface IMutableGraph<V, E = unknown> { | ||
/** | ||
* Add nodes to the graph. | ||
* Return the number of nodes added. | ||
* @param nodes | ||
*/ | ||
insert: (...nodes: V[]) => number; | ||
/** | ||
* Remove nodes from the graph. | ||
* Return the number of nodes removed. | ||
* @param nodes | ||
*/ | ||
remove: (...nodes: V[]) => number; | ||
/** | ||
* Create an edge from the source node to the target node. Return true if a new | ||
* edge is created, otherwise false. | ||
* @param source | ||
* @param target | ||
*/ | ||
connect: (source: V, target: V, value?: any) => boolean; | ||
/** | ||
* Remove the edge from source to target. | ||
* Return true if an edge is removed, otherwise false. | ||
* @param source | ||
* @param target | ||
*/ | ||
disconnect: (source: V, target: V, value?: any) => boolean; | ||
} | ||
export interface IGeneralNodeGraph<V, E = unknown> extends IReadonlyGeneralNodeGraph<V, E>, IMutableGraph<V, E> { | ||
} | ||
export interface IWeightedGraph<V, E> extends IReadonlyWeightedGraph<V, E>, IMutableGraph<V, E> { | ||
/** | ||
* Create an edge from the source node to the target node. | ||
* Return true if a new edge is created, otherwise false. | ||
* @param source | ||
* @param target | ||
*/ | ||
connect: (source: V, target: V, value: E) => boolean; | ||
/** | ||
* Remove the edge from source to target. | ||
* Return true if an edge is removed, otherwise false. | ||
* | ||
* If a value is given, then the edge is removed if and only if the value of the | ||
* edge in the graph is equal to the given value. | ||
* @param source | ||
* @param target | ||
*/ | ||
disconnect: (source: V, target: V, value?: E) => boolean; | ||
} | ||
//# sourceMappingURL=GraphInterface.d.ts.map |
@@ -5,4 +5,8 @@ export declare enum GraphType { | ||
WeightedUndirected = "WeightedUndirected", | ||
NonWeightedUndirected = "NonWeightedUndirected" | ||
NonWeightedUndirected = "NonWeightedUndirected", | ||
ReadonlyWeightedDirected = "ReadonlyWeightedDirected", | ||
ReadonlyNonWeightedDirected = "ReadonlyNonWeightedDirected", | ||
ReadonlyWeightedUndirected = "ReadonlyWeightedUndirected", | ||
ReadonlyNonWeightedUndirected = "ReadonlyNonWeightedUndirected" | ||
} | ||
//# sourceMappingURL=GraphType.d.ts.map |
@@ -10,3 +10,7 @@ "use strict"; | ||
GraphType["NonWeightedUndirected"] = "NonWeightedUndirected"; | ||
GraphType["ReadonlyWeightedDirected"] = "ReadonlyWeightedDirected"; | ||
GraphType["ReadonlyNonWeightedDirected"] = "ReadonlyNonWeightedDirected"; | ||
GraphType["ReadonlyWeightedUndirected"] = "ReadonlyWeightedUndirected"; | ||
GraphType["ReadonlyNonWeightedUndirected"] = "ReadonlyNonWeightedUndirected"; | ||
})(GraphType = exports.GraphType || (exports.GraphType = {})); | ||
//# sourceMappingURL=GraphType.js.map |
@@ -1,2 +0,2 @@ | ||
import { GraphInterface } from '../types/GraphInterface'; | ||
import { IReadonlyGeneralNodeGraph } from '../types/GraphInterface'; | ||
/** | ||
@@ -13,3 +13,3 @@ * Finds the shortest path from the given start node to the given end node. | ||
*/ | ||
export declare const findShortestPath: <V, E>(graph: GraphInterface<V, E>, start: V, end: V) => { | ||
export declare const findShortestPath: <V, E>(graph: IReadonlyGeneralNodeGraph<V, E>, start: V, end: V) => { | ||
path: V[]; | ||
@@ -16,0 +16,0 @@ pathSize: number; |
@@ -1,7 +0,7 @@ | ||
import { GraphInterface } from '../types/GraphInterface'; | ||
import { IReadonlyGeneralNodeGraph } from '../types/GraphInterface'; | ||
import { GraphType } from '../types/GraphType'; | ||
import { WeightedDirectedGraph } from '../WeightedDirectedGraph'; | ||
import { DirectedGraph } from '../DirectedGraph'; | ||
import { WeightedUndirectedGraph } from '../WeightedUndirectedGraph'; | ||
import { UndirectedGraph } from '../UndirectedGraph'; | ||
import { DirectedGraph, WeightedDirectedGraph } from '../mutable/DirectedGraphs'; | ||
import { UndirectedGraph, WeightedUndirectedGraph } from '../mutable/UndirectedGraphs'; | ||
import { ReadonlyUndirectedGraph, ReadonlyWeightedUndirectedGraph } from '../readonly/ImmutableUndirectedGraphs'; | ||
import { ReadonlyDirectedGraph, ReadonlyWeightedDirectedGraph } from '../readonly/ImmutableDirectedGraphs'; | ||
declare type CastedType<V, E> = { | ||
@@ -19,2 +19,14 @@ type: GraphType.WeightedDirected; | ||
graph: UndirectedGraph<V, E>; | ||
} | { | ||
type: GraphType.ReadonlyWeightedUndirected; | ||
graph: ReadonlyWeightedUndirectedGraph<V, E>; | ||
} | { | ||
type: GraphType.ReadonlyWeightedDirected; | ||
graph: ReadonlyWeightedDirectedGraph<V, E>; | ||
} | { | ||
type: GraphType.ReadonlyNonWeightedDirected; | ||
graph: ReadonlyDirectedGraph<V, E>; | ||
} | { | ||
type: GraphType.ReadonlyNonWeightedUndirected; | ||
graph: ReadonlyUndirectedGraph<V, E>; | ||
}; | ||
@@ -32,4 +44,4 @@ /** | ||
*/ | ||
export declare const castExplicitly: <V, E>(g: GraphInterface<V, E>) => CastedType<V, E>; | ||
export declare const castExplicitly: <V, E>(g: IReadonlyGeneralNodeGraph<V, E>) => CastedType<V, E>; | ||
export {}; | ||
//# sourceMappingURL=GetExplicitGraph.d.ts.map |
@@ -17,27 +17,38 @@ "use strict"; | ||
exports.castExplicitly = function (g) { | ||
switch (g.getGraphType()) { | ||
var type = g.getGraphType(); | ||
switch (type) { | ||
case GraphType_1.GraphType.ReadonlyWeightedDirected: | ||
return { | ||
type: type, graph: g | ||
}; | ||
case GraphType_1.GraphType.ReadonlyNonWeightedDirected: | ||
return { | ||
type: type, graph: g | ||
}; | ||
case GraphType_1.GraphType.ReadonlyWeightedUndirected: | ||
return { | ||
type: type, graph: g | ||
}; | ||
case GraphType_1.GraphType.ReadonlyNonWeightedUndirected: | ||
return { | ||
type: type, graph: g | ||
}; | ||
case GraphType_1.GraphType.WeightedDirected: | ||
return { | ||
type: GraphType_1.GraphType.WeightedDirected, | ||
graph: g | ||
type: type, graph: g | ||
}; | ||
case GraphType_1.GraphType.NonWeightedDirected: | ||
return { | ||
type: GraphType_1.GraphType.NonWeightedDirected, | ||
graph: g | ||
type: type, graph: g | ||
}; | ||
case GraphType_1.GraphType.WeightedUndirected: | ||
return { | ||
type: GraphType_1.GraphType.WeightedUndirected, | ||
graph: g | ||
type: type, graph: g | ||
}; | ||
case GraphType_1.GraphType.NonWeightedUndirected: | ||
return { | ||
type: GraphType_1.GraphType.NonWeightedUndirected, | ||
graph: g | ||
type: type, graph: g | ||
}; | ||
default: | ||
throw new Error('No case found'); | ||
} | ||
}; | ||
//# sourceMappingURL=GetExplicitGraph.js.map |
@@ -1,2 +0,2 @@ | ||
import { GraphInterface } from '../types/GraphInterface'; | ||
import { IGeneralNodeGraph, IReadonlyGeneralNodeGraph } from '../types/GraphInterface'; | ||
/** | ||
@@ -8,3 +8,3 @@ * Creates a clone of the given graph. The clone is a new graph object instance that | ||
*/ | ||
export declare const clone: <V, E>(g: GraphInterface<V, E>) => GraphInterface<V, E>; | ||
export declare const clone: <V, E>(g: IReadonlyGeneralNodeGraph<V, E>) => IGeneralNodeGraph<V, E>; | ||
//# sourceMappingURL=GraphClone.d.ts.map |
@@ -26,6 +26,4 @@ "use strict"; | ||
var GraphType_1 = require("../types/GraphType"); | ||
var WeightedDirectedGraph_1 = require("../WeightedDirectedGraph"); | ||
var DirectedGraph_1 = require("../DirectedGraph"); | ||
var WeightedUndirectedGraph_1 = require("../WeightedUndirectedGraph"); | ||
var UndirectedGraph_1 = require("../UndirectedGraph"); | ||
var DirectedGraphs_1 = require("../mutable/DirectedGraphs"); | ||
var UndirectedGraphs_1 = require("../mutable/UndirectedGraphs"); | ||
/** | ||
@@ -47,14 +45,17 @@ * Creates a clone of the given graph. The clone is a new graph object instance that | ||
case GraphType_1.GraphType.WeightedDirected: | ||
clonedGraph = new WeightedDirectedGraph_1.WeightedDirectedGraph(g.toKeyFn); | ||
case GraphType_1.GraphType.ReadonlyWeightedDirected: | ||
clonedGraph = new DirectedGraphs_1.WeightedDirectedGraph(g.toKeyFn); | ||
break; | ||
case GraphType_1.GraphType.NonWeightedDirected: | ||
clonedGraph = new DirectedGraph_1.DirectedGraph(g.toKeyFn); | ||
case GraphType_1.GraphType.ReadonlyNonWeightedDirected: | ||
clonedGraph = new DirectedGraphs_1.DirectedGraph(g.toKeyFn); | ||
break; | ||
case GraphType_1.GraphType.WeightedUndirected: | ||
clonedGraph = new WeightedUndirectedGraph_1.WeightedUndirectedGraph(g.toKeyFn); | ||
case GraphType_1.GraphType.ReadonlyWeightedUndirected: | ||
clonedGraph = new UndirectedGraphs_1.WeightedUndirectedGraph(g.toKeyFn); | ||
break; | ||
case GraphType_1.GraphType.NonWeightedUndirected: | ||
clonedGraph = new UndirectedGraph_1.UndirectedGraph(g.toKeyFn); | ||
case GraphType_1.GraphType.ReadonlyNonWeightedUndirected: | ||
clonedGraph = new UndirectedGraphs_1.UndirectedGraph(g.toKeyFn); | ||
break; | ||
default: throw new Error('This case for clone has not been implemented'); | ||
} | ||
@@ -61,0 +62,0 @@ var nodes = g.nodes(); |
@@ -1,2 +0,2 @@ | ||
import { GraphInterface } from '../types/GraphInterface'; | ||
import { IReadonlyGeneralNodeGraph } from '../types/GraphInterface'; | ||
/** | ||
@@ -10,3 +10,3 @@ * Returns true if the given graph has a cycle and false otherwise, | ||
*/ | ||
export declare const hasCycle: <V>(graph: GraphInterface<V, unknown>) => boolean; | ||
export declare const hasCycle: <V>(graph: IReadonlyGeneralNodeGraph<V, unknown>) => boolean; | ||
//# sourceMappingURL=HasCycle.d.ts.map |
@@ -140,5 +140,9 @@ "use strict"; | ||
case GraphType_1.GraphType.WeightedDirected: | ||
case GraphType_1.GraphType.ReadonlyWeightedDirected: | ||
case GraphType_1.GraphType.ReadonlyNonWeightedDirected: | ||
return hasCycleInDirectedGraph(graph); | ||
case GraphType_1.GraphType.NonWeightedUndirected: | ||
case GraphType_1.GraphType.WeightedUndirected: | ||
case GraphType_1.GraphType.ReadonlyNonWeightedUndirected: | ||
case GraphType_1.GraphType.ReadonlyWeightedUndirected: | ||
return hasCycleInUndirectedGraph(graph); | ||
@@ -145,0 +149,0 @@ } |
@@ -1,3 +0,3 @@ | ||
export declare const parse: <V, E = unknown>(jsonString: string, keyFunction?: ((v: V) => string) | undefined) => import("../../types/GraphInterface").GraphInterface<V, E> | undefined; | ||
export declare const stringify: <V, E>(graph: import("../../types/GraphInterface").GraphInterface<V, E>) => string; | ||
export declare const parse: <V, E = unknown>(jsonString: string, keyFunction?: ((v: V) => string) | undefined) => import("../../types/GraphInterface").IGeneralNodeGraph<V, E> | undefined; | ||
export declare const stringify: <V, E>(graph: import("../../types/GraphInterface").IReadonlyGeneralNodeGraph<V, E>) => string; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,3 +0,3 @@ | ||
import { GraphInterface } from '../../types/GraphInterface'; | ||
export declare const parse: <V, E = unknown>(jsonString: string, keyFunction?: ((v: V) => string) | undefined) => GraphInterface<V, E> | undefined; | ||
import { IGeneralNodeGraph } from '../../types/GraphInterface'; | ||
export declare const parse: <V, E = unknown>(jsonString: string, keyFunction?: ((v: V) => string) | undefined) => IGeneralNodeGraph<V, E> | undefined; | ||
//# sourceMappingURL=ParseGraphJson.d.ts.map |
@@ -1,3 +0,3 @@ | ||
import { GraphInterface } from '../../types/GraphInterface'; | ||
export declare const stringify: <V, E>(graph: GraphInterface<V, E>) => string; | ||
import { IReadonlyGeneralNodeGraph } from '../../types/GraphInterface'; | ||
export declare const stringify: <V, E>(graph: IReadonlyGeneralNodeGraph<V, E>) => string; | ||
//# sourceMappingURL=StringifyGraph.d.ts.map |
{ | ||
"name": "graphs-for-js", | ||
"version": "0.3.0", | ||
"description": "Some JavaScript implementation of a graph data structure.\nFeatures:\n\t- Insert and remove nodes. \n\t- Connect and disconnect nodes. \n\t- Algorithms for graph structures.", | ||
"version": "0.4.0", | ||
"description": "Some JavaScript and TypeScript implementation of a graph data structure.\nFeatures:\n\t- Insert and remove nodes. \n\t- Connect and disconnect nodes. \n\t- Algorithms for graph structures.", | ||
"main": "./dist/index.js", | ||
@@ -14,2 +14,5 @@ "types": "./dist/index.d.ts", | ||
}, | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.org/" | ||
}, | ||
"author": { | ||
@@ -23,6 +26,17 @@ "name": "Anthony Yang", | ||
"graph", | ||
"graphs", | ||
"vertex", | ||
"vertices", | ||
"edge", | ||
"edges", | ||
"algorithm", | ||
"data structure" | ||
"data structure", | ||
"weights", | ||
"cycle", | ||
"path finding", | ||
"shortest path", | ||
"directed", | ||
"undirected", | ||
"javascript", | ||
"typescript" | ||
], | ||
@@ -29,0 +43,0 @@ "nyc": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
153068
107
2090
1