This project is a minimal React.js app bundled with Vite and using Rust compiled into WASM. It features a Dijkstra's algorithm implementation (source code) to efficiently compute the shortest path of a graph and display it.
Screen.Recording.2025-03-26.at.12.14.59.AM.mov
Clone the repository:
git clone [email protected]:PierreLouisLetoquart/react-rust-wasm.git dijgraph
Install dependencies:
cd dijgraph
bun install
Note
You can also use pnpm
or any other package manager. Just replace bun
with your choice.
Start the dev server using bun:
bun run dev
# OR
bun run build
bun run preview
You can now access the app at http://localhost:5173
and drop the example graph file data.csv
to see the shortest path between two nodes.
Note
To modify the Rust code used for Dijkstra's implementation and get more info on the WASM building process, check out this repository.
To create your own graph and use it in the app, make sure it's formatted as follows:
nbrOfNodes
nodeId,x,y
nodeId,x,y
nodeId,x,y
...
nbrOfEdges
sourceId,targetId,weight
sourceId,targetId,weight
...
Warning
The ids must be integers.
This is a super simplified and unoptimized piece of code, so feel free to submit issues or PRs if you’d like. 🙌
Caution
I've encountered a weird bug on Firefox (Zen-browser) and am currently exploring the issue. 🔍
The upload component is taken and adapted from Aceternity