shaunhurryup / lovely-mindmap

Build your own knowledge graph with smiles :-)
MIT License
52 stars 2 forks source link

Feat-Req: Organize Beyond Depth 1 #7

Open tcardlab opened 9 months ago

tcardlab commented 9 months ago

Really convenient and would love to use it more extensively, but the fact that collision detection is limited to immediate children is kind of limiting.

Obsidian_z61cXI7fMv



I'm not terribly familiar with Obsidians API, but here's my uneducated thoughts:

  1. Select node who's children you want to deeply organize (usually Root) and use special hotkey to trigger action. Depth-first search to get deeply connected nodes (break/alert if cycle detected or ignore?). Sum height of children + gap heights (setting) to get chunk sizes, position/align chunks for each depth (given the initially selected node as the center line).
  2. potentially take advantage of the group feature: a. if group has special name (some regex pattern), always deeply organize after updates (+/- node, node resized, connection changed, etc. ). b. use groups to limit scope of nodes you need to consider if that is troubling for any reason.
shaunhurryup commented 9 months ago

Thank you for the validation!

This diagram represents my comprehension of your concept. Are there any discrepancies?

image
tcardlab commented 9 months ago

That seems correct. However, I would like to note that this is just a simple 1 pass solution that guarantees things won't collide. It will work well for balanced/uniform graphs, but as they get larger the graph may skew and become harder to read.

Additionally, you may wish to calculate vertical alignment to distribute nodes vertically in a more aesthetic way:

Here are some examples of using this tallest layer method:

Centering & Spacing Given Max Layer Height:
Obsidian_EPlP9LG8eX
Grouping Chunks For Weak Hierarchical Alignment:
Obsidian_Y1vuXaPY2N


Alternative:

The nature of organizing this uniformly is ultimately a 2-pass problem. So, if you want a more robust solution that maintains hierarchical alignment in non-uniform graphs with non-uniform node sizes, consider the following:

As you can see, the parent height depends on the children and the child alignment depends on the parent height & position. This cyclic dependency points to the fact that two passes are needed to resolve this.

Example:

Given Some Tree Structure:
Obsidian_QcoUVUjdjO
Align With 2-Passes:
Obsidian_1N7o0h7r7n

Conclusion:

Organizing non-uniform trees is an opinionated task, which means someone is bound to be disappointed. The question now becomes, "what the least bad option?". I'll leave this for you to determine for your use-case.


shaunhurryup commented 9 months ago

Wow bro, sorry for the late reply, I'm being forced to learn rust language by my boss😂

You're really doing a lot of thinking ! Surely, the generation of nodes have different solution because we should consider many scenarios.

Tree structure and 2-Passes in the last example is a good choice, they will be released in the next version!