Skip to content

Add GraphList data structure.#236

Merged
waynemwashuma merged 8 commits into
wimaengine:devfrom
waynemwashuma:add-graphlist
Aug 26, 2025
Merged

Add GraphList data structure.#236
waynemwashuma merged 8 commits into
wimaengine:devfrom
waynemwashuma:add-graphlist

Conversation

@waynemwashuma
Copy link
Copy Markdown
Collaborator

@waynemwashuma waynemwashuma commented Aug 26, 2025

Objective

Introduces a new weighted graph data structure called GraphList. It is internally implemented as an adjacency list, making it efficient for representing sparse graphs.
The following are also added to support the structure:

  • GraphNode: Represents a node in the graph.
  • GraphEdge: Represents a directed edge between two nodes.
  • NodeId: Internal reference identifier for nodes.
  • EdgeId: Internal reference identifier for edges.

The graph can do the following:

  • Create and store nodes and edges.
  • Query neighbour nodes for a given node.
  • Retrieve edges originating from a given node.

Note

The current implementation does not provide methods for removing nodes or edges.
Only directed graphs are supported at the moment.Support for undirected graphs may be added in the future.

Solution

N/A

Showcase

const graph = new GraphList<number,undefined>()
const node1 = graph.addNode(3)
const node2 = graph.addNode(2)
const edge1 = graph.addEdge(node1,node2)

Migration guide

N/A

Checklist

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

@waynemwashuma waynemwashuma self-assigned this Aug 26, 2025
@waynemwashuma waynemwashuma added type:enhancement New feature or request mod:datastructure This PR/issue affects datastructure package labels Aug 26, 2025
@waynemwashuma waynemwashuma merged commit 6625241 into wimaengine:dev Aug 26, 2025
5 checks passed
@waynemwashuma waynemwashuma deleted the add-graphlist branch August 26, 2025 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:datastructure This PR/issue affects datastructure package type:enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant