Kemsekov/GraphSharp

Directional Edges

Opened this issue · 3 comments

Hello, I was trying to use your graph library to find the shortest way between multiple recipes.

It's for the following game:
https://neal.fun/infinite-craft/

The idea is that you can combine words to form other words. E.g.:
Fire + Water = Steam

And then:
Earth + Steam = Mud

I have created a Graph using your library which I'd like to use to find out what Path I should take.

The graph now uses intermediate nodes:
Earth => Earth+Steam => Mud
Steam => Earth+Steam

What I want is to have this directional though. Because you can not go from Mud back to Earth.

Is there a way to inform the Dijkstra shortest path finder to only use edges in a specific direction?

P.s. if you're interested in looking at my code / helping me solve it I can give you access. The repo is currently private.

Hello!

Each path finding algorithm have a PathType parameter.

You can see more detailed example here.

https://github.com/Kemsekov/GraphSharp.Samples/blob/main/samples%2FFindPathByMeetInTheMiddle%2FProgram.cs

In general you just invoke methods trough Do object.

var paths = G.Do.FindShortestPathsDijkstra(sourceNodeId,e=>1,pathType:PathType.OutEdges);

var pathToNode = paths.GetPath(targetNodeId);

sourceNode is start of the path

targetNode is end of the path

e=>1 is function to get weight of the edge

PathType.OutEdges is how algorithm build path, so with out edges it will build paths only by directed edges from previous node to next, so if a->b then this pair a->b can be in a path

I don't see the PathType parameter, but I do see the bool undirected. When checking out the code it seems to do the same.

Thanks for the explanation :).

I'm still playing around with the graph a bit on how I can somehow visualize it as the visualization I tried to copy over from one of the samples doens't really work for me.

It seems to put everything in the bottom left corner:
image

But I probably need to write an algorithm for automatic positioning of my graph nodes, or is that also included in the library?

Yeah, I believe you just using old version of library.

I strongly recommend you to update to last nuget version.

I will not lie - I was developing this library for my daily use and it is not backwards compatible.

I will add readme to samples library with institutions how to run so you could play around with it and see how it works.

And about positioning;
Use Arrange method - it will try to assign 2d positions to nodes so distance between them will match weight of edges between them.

I don't have documentation for this project, but I have samples that are small enough and could be run to understand how to work with library.

I will update readme for samples RN
https://github.com/Kemsekov/GraphSharp.Samples