Chirag A.M.
Chirag A.M.

Reputation: 141

Multiple Root Nodes in Cytoscape

I am creating a tree with Breadthfirst layout in Cytoscape.

In layout options, I have set a node as root. But is there a way that I can have 2 nodes as root nodes? I see in cytoscape reference has layout options in following way:

var options = {
  name: 'breadthfirst',
  roots: undefined, // the roots of the trees
};

Now, individual nodes can be set as root nodes by using its ID. For example:

roots: "#a"

How can I do this So I have multiple roots for a single tree as represented in this image?

Multiple Root Tree representation

Upvotes: 3

Views: 1606

Answers (2)

Chirag A.M.
Chirag A.M.

Reputation: 141

Actually, I found out that the easiest way to do it was to use a comma separator. The code will look something like this -

roots: "#a,#b"

Upvotes: 2

Diego Palomares
Diego Palomares

Reputation: 31

I solved that putting a extra class called 'level3' in that nodes and I wrote the next line:

cy.layout({name: 'breadthfirst', directed:false, roots:'node[classes @*="level3"]',padding: 5});

remmember that you can add some different classes to nodes just using a blank space between them

Upvotes: 3

Related Questions