Cytoscape don't load the node and edge attribute from my dot file - graphviz

I am using cytoscape to display a graph i made with graphviz. I installed the add-on dot-app from the cytoscape app store to be able to load my graph.
My graph is loading perfectly, all the edges are connected to the nodes wanted. But the attributes of my nodes and edges aren't showing up.
Here is a simplified example (less attributes, nodes and edges) that is not working :
graph map {
node1 [color="#888888"]
node2 [color="#888888"]
node1 -- node2 [color="#1f78b4"]
}
It generates the following graph :
I managed to find code example of dot file loaded in cytoscape, the following one load the attributes well :
graph toy_example {
graph [bb="-85.648,-58.068,63.891,73.497",outputorder=edgesfirst, overlap=false];
node [fillcolor="#888888",label="\N",style=filled];
1 [height=0.5,pos="-58.648,-8.4777",width=0.75];
2 [height=0.5,pos="36.891,3.383",width=0.75];
2 -- 1 [pos="10.278,0.079128 -2.8626,-1.5522 -18.68,-3.5159 -31.846,-5.1504"];
3 [height=0.5,pos="12.665,-40.068",width=0.75];
3 -- 1 [pos="-9.8989,-30.072 -18.223,-26.385 -27.653,-22.208 -35.986,-18.516"];
3 -- 2 [pos="22.24,-22.895 23.933,-19.858 25.695,-16.698 27.386,-13.665"];
4 [height=0.5,pos="8.8474,55.497",width=0.75];
4 -- 2 [pos="18.03,38.433 21.097,32.734 24.516,26.38 27.592,20.664"];
4 -- 3 [pos="9.5835,37.071 10.264,20.041 11.269,-5.1139 11.944,-22.022"];
}
Generating the following graph :
Do you know why my attributes can't load ?
I tried destroying and creating the view on my graph but it don't do anything. The node table of both graphs only have "shared name" and "name".

If you look at the example that worked, the node color is defined as "fillcolor", not "color". This is because Cytoscape nodes can have two different colors, fillcolor and bordercolor, so the app authors chose to differentiate that by the attribute name. You would have to play around to see what they called the edge color. In Cytoscape it's called "Stroke Color (Unselected)", so you might try "edgecolor" or "strokecolor".
-- scooter

Related

How to add this type of node description by Mermaid?

This is a flowchart pattern that I really like to use and I currently use drawio to draw it:
Notice that there are two kinds of descriptions in the flow chart
description1:How does A get to B
description2:Some properties of B
I know Mermaid can implement the description1 by:
graph TB
A --->|"description1:<br>How does A get to B"| B
But description2 is also very important to me, is there any way to achieve it?
The current workaround:
I use the heading of subgraph instead of description2:
graph TB
A --->|"description1:<br>How does A get to B"| B
subgraph description2:<br>Some properties of B
B
end
But I have to say it's a very ugly temporary solution. So I ask here..
While some types of Mermaid diagrams explicitly support notes (e.g. sequence diagrams), flowcharts do not.
I believe the closest you're going to get is to connect B to itself with an invisible link (~~~):
graph TB
A --->|"description1:<br>How does A get to B"| B
B ~~~|"description2:<br>Some properties of B"| B

Aligning Clusters within Graphviz

I am using Graphviz to automatically create an architecture diagram. I am having the following two problems and was hoping to get assistance.
I am using UUID to uniquely identify a component (example: "a5320de8-a320-11ea-bb37-0242ac130002" [label="Component A"]). When mapping A -> B, I'll get "Component A" -> b0c5e47c. Which is strange. The only way that I've been able to map UUID to UUID is to put quotes around them. Any suggestions?
I want to align clusters in a specific manner and specific direction. I've tried {rank=same; cluster_B, cluster_C, cluster_D}; and "9653369c-a322-11ea-bb37-0242ac130002" -> "aa31adb9-9621-40c2-855c-621832dd8c61" [style=invis] But neither work.
I have three sections within my dot file, they are:
Components (within this section, I list out all 100+ components and color code them based on a specific rule.
Clusters (within this section, I cluster the components into specific 'groupings')
Diagram or mapping (within this section, I then map the different components and clusters).
Here is a sample of my DOT file.
digraph architecture {
#graph [rankdir=LR]
compound=true;
#Compliant
node[fillcolor="#013220" style="filled" shape=square fontcolor="white"];
"a5320de8-a320-11ea-bb37-0242ac130002" [label="Component A"]
"b0c5e47c-a320-11ea-bb37-0242ac130002" [label="Component B"]
#Clusters
#Customer-facing client application cluster
subgraph cluster_A{
label="Client Apps";
"f7b3915d-6b3d-4d4c-bef0-bdabda915c03";
"9912de2b-739a-4c5c-834e-e0c3d09d70d1";
"16bb2066-9293-470e-99ec-c59d8426c0ab";
"641a6601-f4f6-4c06-baa6-e5e232f8abed";
"c5e92b09-a470-4fb6-af5c-e5f7dbeff919";
}
#Diagrams
"f7b3915d-6b3d-4d4c-bef0-bdabda915c03" -> {"35305026-d285-458c-85ad-7eae4e785e84", "76e0e679-42a6-47f0-9164-abc223da07fe"};
76e0e679-42a6-47f0-9164-abc223da07fe" -> "35305026-d285-458c-85ad-7eae4e785108";
}
I get something like:
However, I want to arrange the cluster is a specific way, like:
As you found out, hyphens are not legal characters in a node ID unless the string is quoted. If you want more info: https://www.graphviz.org/doc/info/lang.html
There is no straight-forward to align clusters. Sometime you can force desired alignment by embedding multiple clusters within another cluster to "shrink-wrap" them. For example embed B3 and B4 within cluster B34. But no guarantees.
You can use gvpr to reposition clusters (and their contents) but that can get pretty complex.

how to establish relation between any two nodes of d3 tree layout

I have a D3 tree layout.There will be relation between any two nodes,based on this relation i want to show some connection between 2 nodes.Till now i was using circles.on onmouse circles of the 2 nodes will be in some specified color.circles were not covering images exaclty.so i applied transform but it disturbing some other functionalities.
my sole purpose is to show some connection between any two nodes using circles or something else.i tried applying circles using CSS3 but it didnt work
is there any way to achieve my requirement
If I am understanding you, there are different ways to achieve this, and this is only one.
Consider this:
function highlight() {
var selectedClass = d3.select(this).attr("class");
d3.selectAll("circle")
.style("fill",function(d) {
if ( selectedClass == d3.select(this).attr("class"))
return "magenta";
});
}
Assuming you have established the relationship between any given number of nodes (two or more) by assigning them the same class (perhaps a big assumption), then code like the one above can display such relationship. If you click on one of the nodes (this function is called by the node .on("click"...), the others will also display the desired change, illustrated here by a change in color. Does this help?

Accessing data automatically assigned by force layout

I am creating a network of nodes and edges using force layout. My application has some dynamic nodes (which can be any number determined by backend code). I am allowing the force layout to assign the x and y for these dynamic nodes by itself which it does on calling force.start() function.
Now, there are a different set of nodes which are moving over the edges(eg. cars moving on roads) connecting the static and dynamic nodes. For this animation, I need to get the x and y values from the force.nodes() which it has assigned to the dynamic nodes. I tried the normal dot operator to get the values but it fails to return the actual value.
Below is one of the value of node
[09:13:07.505] ({name:"D_Exit_0", dynamic:true, act_cap:-1, danger:0, index:0, weight:1, x:3014.087389427884, y:513.2901517247882, px:3013.9965777253265, py:513.0782974731648})
The x and y values here are assigned by the force layout.
When I tried node.x, it is returning me a value I had accessed just before accessing this node. However, when I directly print the node using console.log(node) it gives the above output.
Kindly let me know how I can get the dynamic data assigned by the force layout itself i.e. value x: 3014.08.. in above case?
force.nodes() should return an array of all the nodes. To get the x value from one the first one, use force.nodes()[0].x (documentation).
To animate something along the connection between the nodes, you might better off working with force.links(), which returns all the links between nodes. If you're working off of one of the examples, there should be a line of code similar to var link = svg.selectAll(".link"); if there is you could, for example, slowly turn all the links green with:
> link.transition().duration(5000).style("stroke", "green")
If you have any more questions, post the code you have so far on jsfiddle or bl.ocks.org.

Cryptic dot error message for graph with big (sub)clusters

I've written a little tool dumping (in dot format) the dependency graph of a project where all the files living in the same directory are gathered in a cluster. When I try to generate a pdf containing the corresponding graph, dot starts to cry:
The command dot -Tpdf trimmedgraph.dot -o graph.pdf produces the cryptic error message Error: install_in_rank clusterReals virtual rank 21 i = 0 an = 0 which does not yield any result on google.
I've tried to edit trimmedgraph.dot manually: turning the subgraph clusterReals into Reals yields a file that can be compiled but all the content of my Reals/ directory is obviously not gathered anymore.
Is there a way to generate only dot-valid files (I was planning to send my patch upstream eventually but if I cannot guarantee that everything will be okay...)?
I've put the two versions of trimmedgraph.dot online but they are rather big and given that I have no idea where the problem is, I cannot really come up with a minimal file recreating the problem.
I think (but couldn't find any documentation about this) cluster names have to be unique within the entire dot file. In your file however, there are two subgraphs called clusterReals.
The solution is to make sure all cluster names are unique - since the name doesn't appear anywhere in the output, you may just use numbers when generating dot files.
A quick test shows that strange things happen when reusing the same cluster name:
digraph dependencies {
subgraph cluster0 {
label="First cluster 0";
Node1;
subgraph cluster0 {
label="Second cluster 0";
Node2;
}
}
subgraph cluster0 {
label="Third cluster 0";
Node3;
}
subgraph cluster1 {
label="Cluster 1";
Node4;
subgraph cluster0 {
label="Fourth cluster 0";
Node5;
}
}
}
All the cluster0 seem to be merged together (nodes, label), unless it is not possible because they're included by other clusters. At least that's what it looks like... Since the consequences are unpredictable (error in your case), I'd try to always use unique cluster names.

Resources