简体   繁体   English

如何通过Cytoscape.js使用可乐按颜色和形状分离节点

[英]How to separate nodes by color and shape using Cola through Cytoscape.js

I have a system of large biological networks that have a mix of directed and undirected edges. 我有一个大型生物网络系统,其中包含有向边和无向边。 Within these networks we have three key node shapes: triangle, ellipse, and rectangle. 在这些网络中,我们具有三个关键节点形状:三角形,椭圆形和矩形。 The nodes are either gray or colored. 节点为灰色或彩色。 I am trying to see if, with cytoscape-cola, I am able to separate the shapes out quickly and consistently, regardless of graph size, such that triangles are at the top of the graph and that rectangles are at the bottom, with ellipses in between. 我正在尝试使用cytoscape-cola,无论图形大小如何,我都能快速,一致地分离出形状,使得三角形位于图形的顶部,矩形位于底部,并且椭圆形位于之间。 Ideally, I would like to also be able to separate them by color, as shown by this example 理想情况下,我也希望能够按颜色将它们分开,如本示例所示

Thus far, I have had limited success. 到目前为止,我取得的成就有限。 I have tried adding in source and sink nodes that connect to all of the triangles and rectangles, respectively, then apply a flow. 我尝试添加分别连接到所有三角形和矩形的源节点和宿节点,然后应用流。 This however, does not work as the graph seems to be overconstrained. 但是,此操作不起作用,因为该图似乎过于受限。 I can directly align each node, but this is slow and ineffective for a general solution. 我可以直接对齐每个节点,但这对于一般的解决方案来说是缓慢且无效的。 I have also tried compound nodes, which gets me closer, but it is difficult to set the location of the compound node as it relies upon the location of its children, which brings me back to step one. 我还尝试了复合节点,这使我离得更近,但是由于它取决于子节点的位置,因此很难设置复合节点的位置,这使我回到了第一步。 Finally, I have had the best luck with applying cola to subgraphs, however, it requires me to calculate the location of bounding boxes for every subgraph, which becomes more difficult with increasing colors. 最终,我对将可乐应用于子图非常幸运,但是,这要求我计算每个子图的边界框的位置,随着颜色的增加,边界框的位置变得更加困难。

Any assistance will be greatly appreciated. 任何帮助将不胜感激。

Force-directed layouts will organise the graph based on topology rather than classification. 力导向的布局将基于拓扑而不是分类来组织图形。 For your usecase, it sounds like you should be using a more deterministic layout like grid --- grouping the graph into three rows. 对于您的用例,听起来您应该使用更具确定性的布局,例如网格-将图形分为三行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM