Random-walk-on-graph

#1

Hi, I’m working to a project in Rust and I should design and implement a software system for the management of weighted direct graphs that is able to read / write the graph (CSV format) from file and to carry out random walk on the graph.
I think I need to use the pathfinding crate but I would like to have some suggestions, in particular to create a random walk.

Thanks for attemption.

0 Likes

#2

Use petgraph for the graph logic.
For serialising I would recommend to use serde.

0 Likes

#3

how would you write a graph on file.txt?

0 Likes

#4

It’s your (home-)work, isn’t it? :wink:

Spoiler

If you really want a CSV it’s kind of tricky, because AFAIK CSV is “structured”, e.g. there are no variable lengths allowed. But if you don’t pay much attention to that detail you could make it

Node_ID;Name;Node_A;Node_B;Node_C;...
...

where Node_ID is an ID, Name can be some arbitrary name and Node_A, Node_B, … are outgoing edges to the nodes with that ID.
You could also prefix it with < or > for incoming and outgoing nodes if you want. I don’t know your usecase :wink:

0 Likes

#5

I wrote the adjacency matrix of my graph in file.txt and then I wrote a code to import it in the main. It’s ok?

0 Likes