Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fast-graph

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-graph - npm Package Compare versions

Comparing version 0.0.5-beta to 1.0.0

2

package.json
{
"name": "fast-graph",
"version": "0.0.5-beta",
"version": "1.0.0",
"description": "A fast implementation of graph data structure",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -116,2 +116,9 @@ # fast-graph

});
// Use DFS to visit all nodes in the graph async
await myGraph.dfsAsync(async node => {
await yourExternalApiCall(node);
return SearchAlgorithmNodeBehavior.continue;
});
```

@@ -121,2 +128,93 @@

## Algorithm guidelines
### Depth-First Search (DFS):
1. **Traversal:**
- DFS is commonly used for traversing or searching through a graph or tree data structure.
- It explores as far as possible along each branch before backtracking.
2. **Connected Components:**
- DFS is used to identify connected components in an undirected graph.
3. **Cycle Detection:**
- DFS can be employed to detect cycles in a graph. If during the traversal, you encounter an already visited node, it indicates the presence of a cycle.
4. **Pathfinding:**
- DFS can help find paths between two nodes in a graph.
5. **Maze Solving:**
- DFS is useful for solving mazes and exploring possible paths.
6. **Backtracking:**
- It's a fundamental algorithm for backtracking problems.
### Breadth-First Search (BFS):
1. **Shortest Path:**
- BFS is commonly used to find the shortest path between two nodes in an unweighted graph.
2. **Connected Components:**
- Similar to DFS, BFS can identify connected components in an undirected graph.
3. **Level Order Traversal:**
- BFS is effective for performing level-order traversal of a tree or graph.
4. **Maze Solving:**
- BFS can be used for maze-solving algorithms.
5. **Network Routing:**
- BFS is applied in network routing protocols to discover the shortest path.
### Kahn's Topological Sort:
1. **Directed Acyclic Graph (DAG):**
- Kahn's algorithm is used for topological sorting of nodes in a Directed Acyclic Graph (DAG).
2. **Dependency Resolution:**
- In project management and build systems, Kahn's algorithm helps resolve dependencies between tasks or components.
3. **Course Scheduling:**
- In academic settings, Kahn's algorithm can be used for scheduling courses, ensuring prerequisites are met.
4. **Task Execution Order:**
- Kahn's algorithm is useful for determining the order of task execution when tasks have dependencies.
5. **Compiler Dependency Analysis:**
- In compilers, Kahn's algorithm aids in analyzing and resolving dependencies between modules.
### General Considerations:
- **Use DFS for...**
- Exploring all possible paths in a graph.
- Cycle detection.
- Backtracking problems.
- **Use BFS for...**
- Finding the shortest path in an unweighted graph.
- Level order traversal.
- Maze solving.
- **Use Kahn's Algorithm for...**
- Topological sorting in Directed Acyclic Graphs.
- Dependency resolution in various applications.
- Task scheduling and execution order determination.
Each algorithm has its strengths and is well-suited for specific types of problems. The choice depends on the nature of the problem you're solving and the characteristics of your data.
## Contributing

@@ -123,0 +221,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc