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
Force-directed Graph (DAG mode) Support Cycle #199
Comments
I replaced throw in the traverse function with "continue;" in force-graph-module in my node modules, so I won't get any error and nodes become visible circular, now how can I put the root node in the centre and simulate the dag mode? :D
#https://github.com/vasturiano/force-graph/blob/master/src/dagDepths.js |
@arrow891 thanks for reaching out. I've added a onDagError={loopNodeIds => {}} you're essentially allowing the DAG processing to continue after encountering a cycle. This is not recommended as graph directionality cannot be guaranteed and the result will be a best effort. But it can help a case in which the graph structure is mostly a dag except for some small negligible loop segments. TL;DR use with caution. 😄 |
@vasturiano I do appreciate for the time you have assessed to save my job, you saved 50% of my job, yet I have to save the rest 50% 😂, because of the confidential data I'm not able to share anything of my code or etc. But so far the thing that happens is similar to this : As you can see, the root node is also placed in the circle position, while with the dagMode its expected to be something like this: Sorry for my bad drawing :)) but I meant the root node should be placed in the center, I can provide group property in my data so that it can distinguish which one is the root or something else, I hope you can suggest me something before I run out of time 😅 thank you so much in advance |
@arrow891 maybe you can try using a dagMode="radialOut" |
@vasturiano The example pictures that I shared was the results of using radialout or radialin, I also tried to trace your code to find out it's mechanism, but having the lack of time intercepted me, I will try to provide an example data if possible but I'm not sure if I can |
@arrow891 if you wish to fix the |
@vasturiano I've tried to set fx and fy in nodeCanvasObject or even in the onDagError, and did not work, specially when we have a mesh graph, I think the reverse vertices are causing the issues, I will try to simulate the situation in a codesandbox or provide the data ASAP |
@vasturiano I tried my best but I failed, here is my approach tu use grouping nodes and position them circular around the root node, I used d3Force to position them with forceX and forceY, or forceRadial, but this is too much beyond my knowledge, do you have any suggestions how to achieve this? |
@arrow891 the graph you've drawn does not appear to have any cycles in it (not sure because it doesn't include link directionality), so the If you want to make |
@vasturiano Thanks for replying so fast, I provided a sandbox to show an example data with cycle and |
@arrow891 for that purpose I would suggest to not use the You can add a new force to the system using the Something like: myGraphRef.current.d3Force('myRadialForce',
forceRadial()
.radius(node => node.group * LEVEL_GAP)
.strength(1)
); You can import forceRadial from https://github.com/d3/d3-force |
@vasturiano I have updated my sandbox , somehow it works but there 2 questions: |
myGraphRef.current.d3Force('myRadialForce', null); Or alternatively, you can just set its intensity to myGraphRef.current.d3Force('myRadialForce').strength(0);
myGraphRef.current.d3Force('myRadialForce').radius(node => node.group === 'a' ? 30 : 60); |
@vasturiano it's me again :D I needed more codes and I found some, but now I am facing another issue, please check this sandbox to see what happens to disjoint nodes :D The disjoint nodes overlapping on each other while they should be separated as much as the lines around them, if I change the forceCenter, then mapping of the nodes will be interrupt. |
@arrow891 from that example is not overly clear what the intent/issue is. Can you explain what is not behaving as you would expect? |
@vasturiano Ok, please consider this scenario, we have a disjoint graph with 3 root nodes, each other node is in the specific group base on data, we want to place each node around its root base on the group index, so we have a 3 organized graph, when you open the example, roots and their childrens are not organized, when you click on the button, each node will move to its position around the root, but roots overlaps on each other ! The issue : after applying forces, each root node and its childrens should be visible correctly, but in the demo, all root nodes go to the 0,0 position, I couldn't separate centers without affecting the categorization. |
@arrow891 perhaps I'm missing something but if you'd like to separate the various disjointed clusters, why not give them different radial centers, using the |
@vasturiano probably I'm missing something, first of all: 2- how to avoid collision between the outer circles around each disjoint root? Something like the last circle repel other outer circles of other roots. |
1 - Yes, unfortunately the 2 - Since you're in control of the radial centers, that's the only thing you can really manipulate to prevent collisions. Now, what you could do is set a collision force between all the root nodes, with the collision radius as large as the outer ring of that cluster. Then, you dynamically set the radial force center of each cluster (at every tick) to the coordinates of its root node (that's been affected by the collision force). It will probably take a bit of calibration to get it just right, but it could be done. |
1- I tried multiple forceRadial but the same results, would you please help me with the sandbox or more practical examples? 2- setting forceCollide for each root node, not only affects on distance between roots, but also affects the distance between root and its dependent nodes which is not a good solution :( |
@vasturiano well, finally I solved the problem, it was something beyond the library support and I had to modify the library itself in order to achieve this goal, thank you |
Hi, I've been asked to provide dag mode support for graphs with or without cycles, there are 2 issues:
I would be appreciated if you suggest me how to handle these demands or any hints about how to modify the source code to achieve this goal. thanks in advance.
The text was updated successfully, but these errors were encountered: