Reputation: 1737
I'm modifying the breadthfirst example on the Cytoscape site (the one with the cat at the top). When I create a new "predators" node and put cat and dog nodes in it, then change the edge that goes from cat to bird to now go from predators to bird, the layout gets completely messed up.
How can I use compound nodes with breadthfirst, or is there another layout I should be using? I don't want anything fancy, I just want the compound nodes to follow the same rules that a normal node follows.
Upvotes: 1
Views: 1948
Reputation: 12242
I understand you want something simple, but the problem is that compound graphs are more complex than ordinary graphs.
A compound node does not have independent dimensions: http://js.cytoscape.org/#notation/compound-nodes
A layout has to take this into account and have a generic, customisable algorithm for placing the children such that the constraints for both the children and the parents are satisfied.
This doesn't fit with most layouts, and so only those layouts marked with explicit compound support will give you the results you're looking for. Ordinary layouts ignore compound nodes.
Typically, force-directed (physics simulation) layouts work best with compound graphs -- like Cola or Cose Bilkent. Tree-like layouts don't. There are too many cases where satisfying the layout rules for compound graphs would be impossible.
You can try Cola with the directionality constraint to make the result tree-like. Or you can write your own layout using the API if your compound graphs are simple enough and you can make enough assumptions about the topology of your graphs.
Upvotes: 1