Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ReversedBidirectionalGraph in Search #59

Open
thempen opened this issue Apr 6, 2022 · 1 comment
Open

Using ReversedBidirectionalGraph in Search #59

thempen opened this issue Apr 6, 2022 · 1 comment
Labels
support Issue related to user needing some support.

Comments

@thempen
Copy link

thempen commented Apr 6, 2022

Hi,

I am a little confused with building and using the ReversedBidirectionalGraph. I came on to that through #46 .

What i have: A directed graph with loops and parallel edges. I do have a single root vertex and a single final vertex.

What i want to do:

  • Building a BFS tree from the root vertex.
  • Building a BFS tree from the final vertex reversed edges. (considering the final vertex would be the new root and every paths in the graph to search is pointing in the opposit direction.

My approach and problem:
I tried to use the ReversedBidirctionalGraph with the intention on not needing to build a reversed graph manually. This would also be problematic because i do some dynamic Id Management in that, referencing to certain objects. With building new Vertices and Edges, there would be new unique Ids, not referencing to the correct objects anymore. So... yeah...

I tried to do something like this (just pseudocode, because i didn't get it running in a clean way):

ReversedBidirectionalGraph<MyNode, MyEdge> reversedGraph; // somehow filled
BFS<MyNode, MyEdge> topDown = new BFS<MyNode, MyEdge>(reversedGraph.Original)
//adding topDown to some observer

BFS<MyNode, MyEdge> bottomUp= new BFS<MyNode, MyEdge>(reversedGraph)
//adding bottomUp to some observer

I don't know how to do this in a clean way, because I always run in to data type problems with the SReversedEdge struct leading to a mess of type conversions and castings on my side.

Can you give me an Idea on how to work with the reversed graph?

@KeRNeLith
Copy link
Owner

Hello!

The ReversedBidirectionalGraph is indeed dynamic representation of a graph as a reversed one. BTW it indeed use some struct (SReversedEdge) to not create/alterate objects from the original graph. I would say that it's the cost of dynamic feature.

Otherwise we would need a representation that create edge object by reverting Source and Target. The main issue would certainly be that this would imply using reflection to make the ctor call and also assuming that the edge object has a ctor with source and target in this order.
Hum or maybe by giving an edge factory so that this would solve the reflection issue. BTW we will end having different edge instances. Wouldn't it be an issue for you if I understand well?

There are several possible additions that can be made for the library:

  • Dynamic representation with specific edge structure (current implementation)
  • Dynamic representation with similar edge structure
  • Static representation with specific edge structure (reversed edge creation is done only once)
  • Static representation with similar edge structure (alternate edge creation is done only once)

I'm not sure how useful each would be?

@KeRNeLith KeRNeLith added the support Issue related to user needing some support. label May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Issue related to user needing some support.
Projects
None yet
Development

No branches or pull requests

2 participants