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

Multiple disconnected graph components #12

Closed
grovesNL opened this issue Jun 30, 2022 · 2 comments
Closed

Multiple disconnected graph components #12

grovesNL opened this issue Jun 30, 2022 · 2 comments

Comments

@grovesNL
Copy link

Hi! 👋 I've been trying out this library and it seems to work great for my use case.

There is a small problem that I'm running into where I don't know the longest path ahead of time, and I have multiple disconnected graph components, e.g.

[
    // First component containing 1, 2, 3
    { source: '1', target: '2' },
    { source: '2', target: '3' },
    // Second component containing 4, 5, 6
    { source: '4', target: '5' },
    { source: '5', target: '6' },
];

When I try to use get, I don't know which starting nodes to use or which components exist, so I'd have to do something like:

  • detect all disconnected components (e.g. run DFS to discover all nodes in each connected component)
  • determine the longest path for each component so I can call get per component (e.g. if I do something like DFS to discover all disconnected components, this is easy enough)

I can do this on my side, but I was wondering if it makes sense to add this directly into digl since DFS is already being applied to the graph there anyway. For now I've been working around it by adding a fake node that's connected to all nodes, but this doesn't work well with addEmptySpots

@vycke
Copy link
Owner

vycke commented Jul 1, 2022

Interesting use-case. It sparks some ideas on my side:

  • It should be possible to determine the 'root' in both components of your example automatically. If. this is build in DIGL directly, indicating the 'root' would become optional. Some graphs dont have a dedicated 'root' (loops), or can have several 'roots' (e.g. state machines with different entry points). But in the majority of the cases it can just be build in.
  • Instead of returning a single 'ranking' for a single graph, it should be possible to return an array of 'rankings' for each of the individual graphs. This also allows for disconnected nodes to be part of the output instead of just being left out.
  • Indicating an array of 'roots' that can be used, in case of multiple separate graphs.

It should definitely be possible to build this into DIGL, so I'll have a go at it.

@vycke
Copy link
Owner

vycke commented Jan 2, 2023

Part of v2.0.0

@vycke vycke closed this as completed Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants