mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2026-03-13 08:51:02 +08:00
Upgrade dependencies and fix ESLint issues.
This commit is contained in:
@@ -66,7 +66,7 @@ export default function articulationPoints(graph) {
|
||||
// Get minimum low discovery time from all neighbors.
|
||||
/** @param {GraphVertex} neighbor */
|
||||
visitedSet[currentVertex.getKey()].lowDiscoveryTime = currentVertex.getNeighbors()
|
||||
.filter(earlyNeighbor => earlyNeighbor.getKey() !== previousVertex.getKey())
|
||||
.filter((earlyNeighbor) => earlyNeighbor.getKey() !== previousVertex.getKey())
|
||||
/**
|
||||
* @param {number} lowestDiscoveryTime
|
||||
* @param {GraphVertex} neighbor
|
||||
|
||||
@@ -53,7 +53,7 @@ export default function graphBridges(graph) {
|
||||
|
||||
// Check if current node is connected to any early node other then previous one.
|
||||
visitedSet[currentVertex.getKey()].lowDiscoveryTime = currentVertex.getNeighbors()
|
||||
.filter(earlyNeighbor => earlyNeighbor.getKey() !== previousVertex.getKey())
|
||||
.filter((earlyNeighbor) => earlyNeighbor.getKey() !== previousVertex.getKey())
|
||||
.reduce(
|
||||
/**
|
||||
* @param {number} lowestDiscoveryTime
|
||||
|
||||
@@ -8,9 +8,9 @@ import DisjointSet from '../../../data-structures/disjoint-set/DisjointSet';
|
||||
export default function detectUndirectedCycleUsingDisjointSet(graph) {
|
||||
// Create initial singleton disjoint sets for each graph vertex.
|
||||
/** @param {GraphVertex} graphVertex */
|
||||
const keyExtractor = graphVertex => graphVertex.getKey();
|
||||
const keyExtractor = (graphVertex) => graphVertex.getKey();
|
||||
const disjointSet = new DisjointSet(keyExtractor);
|
||||
graph.getAllVertices().forEach(graphVertex => disjointSet.makeSet(graphVertex));
|
||||
graph.getAllVertices().forEach((graphVertex) => disjointSet.makeSet(graphVertex));
|
||||
|
||||
// Go trough all graph edges one by one and check if edge vertices are from the
|
||||
// different sets. In this case joint those sets together. Do this until you find
|
||||
|
||||
@@ -75,7 +75,7 @@ export default function eulerianPath(graph) {
|
||||
[edgeToDelete] = currentEdges;
|
||||
} else {
|
||||
// If there are many edges left then we need to peek any of those except bridges.
|
||||
[edgeToDelete] = currentEdges.filter(edge => !bridges[edge.getKey()]);
|
||||
[edgeToDelete] = currentEdges.filter((edge) => !bridges[edge.getKey()]);
|
||||
}
|
||||
|
||||
// Detect next current vertex.
|
||||
|
||||
@@ -20,7 +20,7 @@ function isSafe(adjacencyMatrix, verticesIndices, cycle, vertexCandidate) {
|
||||
}
|
||||
|
||||
// Check if vertexCandidate is being added to the path for the first time.
|
||||
const candidateDuplicate = cycle.find(vertex => vertex.getKey() === vertexCandidate.getKey());
|
||||
const candidateDuplicate = cycle.find((vertex) => vertex.getKey() === vertexCandidate.getKey());
|
||||
|
||||
return !candidateDuplicate;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ function hamiltonianCycleRecursive({
|
||||
cycle,
|
||||
}) {
|
||||
// Clone cycle in order to prevent it from modification by other DFS branches.
|
||||
const currentCycle = [...cycle].map(vertex => new GraphVertex(vertex.value));
|
||||
const currentCycle = [...cycle].map((vertex) => new GraphVertex(vertex.value));
|
||||
|
||||
if (vertices.length === currentCycle.length) {
|
||||
// Hamiltonian path is found.
|
||||
|
||||
@@ -33,7 +33,7 @@ export default function kruskal(graph) {
|
||||
const sortedEdges = new QuickSort(sortingCallbacks).sort(graph.getAllEdges());
|
||||
|
||||
// Create disjoint sets for all graph vertices.
|
||||
const keyCallback = graphVertex => graphVertex.getKey();
|
||||
const keyCallback = (graphVertex) => graphVertex.getKey();
|
||||
const disjointSet = new DisjointSet(keyCallback);
|
||||
|
||||
graph.getAllVertices().forEach((graphVertex) => {
|
||||
|
||||
Reference in New Issue
Block a user