anvaka / anvaka/ngraph.subgraph

Breadth first search subgraph

Open
#13 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
8
Forks
3
PR merge metrics
No merged PRs in 30d

Description

I was looking for a simple breath first search implementation and was surprised that there does not seem to be one.

Maybe it makes sense to add one?

Here my code:

```typescript
function getSubGraph(graph: Graph, start: NodeId): Graph {
let subgraph = createGraph();

if (!graph.hasNode(start)) return subgraph;
const startNode = graph.getNode(start)!;

let queue = [startNode];
subgraph.addNode(start, startNode.data);

while (queue.length > 0) {
let currentNode = queue.shift()!;

for (const link of currentNode.links) {
const visitedNode = graph.getNode(link.toId)!;
if (!subgraph.hasNode(visitedNode.id)) {
subgraph.addNode(visitedNode.id, visitedNode.data);
subgraph.addLink(link.fromId, link.toId, link.data);
queue.push(visitedNode);
}
}
}
return subgraph;
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the subgraph entry point and the Graph, NodeId, createGraph, and getSubGraph APIs in ngraph.subgraph. Use the supplied breadth-first traversal as the behavioral reference, including an empty result for a missing start node; done means reachable nodes and links are returned in a subgraph.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
data
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.