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

Find all paths between 2 nodes? #478

Closed
tctco opened this issue Sep 12, 2021 · 4 comments
Closed

Find all paths between 2 nodes? #478

tctco opened this issue Sep 12, 2021 · 4 comments
Assignees

Comments

@tctco
Copy link

@tctco tctco commented Sep 12, 2021

Is your feature request related to a problem? Please describe.
I wonder if there is a way to display all paths between 2 given nodes? I have tried plugins like Journey but it only gives the shortest path using the Dijkstra algorithm and it does not support code fences.

Describe the solution you'd like
I think it would be great if dataview support query like this:

link "muscles" to "bones"
from "anatomy"
where link.hop < 5

and the output could be a nested list like (it would be even better if the result could be displayed in mermaid or some other graph view):

  • muscles
    • biceps
      • humerus
        • bones
      • scapula
        • bones
      • ...
@blacksmithgu
Copy link
Owner

@blacksmithgu blacksmithgu commented Sep 12, 2021

Do you want all shortest paths, all paths of length <= N? There are exponentially many paths between any two nodes in a graph, which would lag out quickly.

@tctco
Copy link
Author

@tctco tctco commented Sep 12, 2021

I think the result should be all simple paths between 2 arbitrary nodes. I originally thought that this feature could be easily implemented with a simple DFS and cut out all branches that exceed a given max depth and didn't think much about the time complexity...

The original motivation for this feature is that as a medical student, I'm struggling with connecting different systems (e.g., cardiovascular system, immune system...) together. It would be great if dataview could help reveal the hidden connections between nodes. Apparently, neither I nor the computer is good at connecting things QAQ...

I will close this issue since it is not feasible due to the high order of time/space complexity. Thank you for your reply.

PS: dataview is a great plugin!!! :)

@tctco tctco closed this Sep 12, 2021
@blacksmithgu
Copy link
Owner

@blacksmithgu blacksmithgu commented Sep 12, 2021

One option would be to compute the shortest path, and then compute all other paths that are at most N (say 1 - 3) longer than the shortest path. This is generally computationally feasible (if a little slow).

I think the coolest thing that could be done here would be to implement a graph viewing extension to Dataview which embeds a graph view that you can filter on. I wonder how feasible that is.

@tctco
Copy link
Author

@tctco tctco commented Sep 12, 2021

I think dataview is quite similar to SQL. After all, it's like writing SQL to me so far. However, the reason that I choose obsidian (or other software that has 2-way links) over Excel is that it takes the whole vault as a graph instead of a table. Unfortunately, the filters function in the graph view is not very handy, which makes the global graph view almost useless as the size of the vault quickly grows (I created nearly 3.5k nodes last semester and my vault will continue to expand at this speed in the following 2-3 years QAQ). I think it would be really useful if dataview could include some NoSQL/graph DB features, and what you have commented sounds truly promising. I'm looking forward to that :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants