I'm trying to draw a deployment diagram of services and servers in our enterprise using dot. For the first iteration, I used neato to draw each service as a box and Prevent overlapping records using graphviz and neato , plus allowing splines, allowed me to get a decent layout with the edges as dependencies.
Now I need to place physical servers inside each of these boxes. First I made each service a subgraph with a name beginning with cluster and then placed the nodes representing the physical servers inside each box. Again, with the help of GraphViz - How to connect subgraphs? I faked out the edges to connect the clusters rather than the nodes. The problem is, that only works in dot. When I use neato to do the layout, it doesn't understand the edges are between clusters, so it moves only the node of the cluster I used to anchor the edge. The result is the cluster boxes are enormous and overlapping.
I hope that makes sense. Is there any way to force neato to keep the nodes in a cluster grouped?
I rethought what I was doing, and instead of using a subgraph for each service with subnodes for each server, I used a record format instead. Each node now looks like
+------------------------------+
| Service name |
+------------------------------+
| server1 | server2 | server 3 |
+------------------------------+
and it's much easier to lay those out :)
Related
I am creating a network graph from some data. Not all the data is connected, leading to individual groups (or clusters? I'm not sure of the right terminology).
Below is an example of what it looks like. (I was using 'neato' here).
Is it possible to get graphviz to detect and draw lines around the individual groups?
I have looked at a number of dot examples with subgraphs. However, that would require me to know up-front which nodes belong in the same group, which means I would have to traverse each node to find all the connected nodes so I can include them in respective subgraphs.
I was hoping the framework can somehow do this for me automatically.
I believe that ccomps (http://www.graphviz.org/pdf/ccomps.1.pdf) (a Graphviz program) can identify disconnected subsets and create a subgraph for each subset. The following (Linux) command will identify these subsets and create a cluster around each.
ccomps -x myfile.gv | sed -e '/digraph .*_cc_/s/digraph /subgraph cluster/' -e '1idigraph N {' -e '$a}'
I have a large, but not really huge(?) graph, with 13 subgraph clusters containing about 100 nodes and 3,147 edges.
Dot crashes on Windows and seg faults on Linux.
This question suggests that the solution is to use neato, rather than dot.
But, this page says
Please note there are some quirks here ... only the DOT and FDP layout methods seem to support subgraphs
My output is a huge, black ball of spaghetti, no matter how far I zoom in. So I removed all of the messages but one, and that showed that the subgrphs appear to be drawn nested in each other.
They are absolutely not nested in the source file; here's a sample, with commercially sensitive names changed:
digraph G {
labelloc="t"; // place the label at the top (b seems to be default)
label="XXX message passing";
rankdir = "LR"
newrank = "true"
subgraph cluster_AAA {
label="AAA"
rank="same"
AAA_1
}
subgraph cluster_BBB {
label="BBB"
rank="same"
BBB_1
BBB_2
}
subgraph cluster_CCC {
label="CCC"
rank="same"
CCC_1
CCC_2
CCC_3
}
That certainly seems to be syntactically correct (the edges follow after).
So, it seems like that linked page was correct:
only the DOT and FDP layout methods seem to support subgraphs
BUT, it also seems like I need neato for a large graph.
What are my options?
[Updtae] I ran fdp and got the following error message
Error: node "xxx" is contained in two non-comparable clusters "AAA" and "BBB"
That seems to give a clue. Is it really the case that a node name may not be used in two clusters?
If so, the solution would seem to be to precede the node names with the cluster name ...
so I do not have a general solution to solve your problem.
But have you had a look at "mars"?
It's a command line tool designed specifically for the use of graphviz programs with very large graphs.
You can find it here: https://github.com/marckhoury/mars
I'm looking for a way to disable edge routing during rendering of dot graphs.
Ideally this would be a per-edge option, but disabling routing altogether would be helpful as well.
The graphs I'm generating represent syntax trees with additional edges from the usage of an identifier to its declaration as shown below.
Simple DAST
Now, this is still mostly readable, but with larger graphs the blue edges get very confusing very quickly, since dot seems to love routing them all over the place.
Complex DAST
I would prefer if they just went in a straight (or curved) line between the two nodes, ignoring all overlap with nodes and other edges.
Unfortunately I've been unable to find a way to achieve this effect and honestly I doubt it is even possible.
A similar question has been asked before, but I decided to open a new one anyway due to the following reasons:
I don't require the nodes to stay in a fixed position
Apart from the blue edges, my graph is always a tree (no edge overlap to worry about)
Running dot in multiple passes is unfortunately not an option for me
The other question is over 6 years old, so maybe a feature was added since then
My attempts so far:
Added "overlap=true" to the graph settings
Added "overlap=true" to individual edges
Neither of these seems to have any effect whatsoever.
The file layout is pretty simple (excerpt):
digraph {
node [shape=Mrecord];
graph [ordering=out, overlap=true, nodesep=0.3, ranksep=1];
...
# ReferenceLiteral rec
node0 -> node40 [style=dashed, color=blue, constraint=false]
node0 [shape=box style=filled label="rec" fillcolor="#cccccc"]
...
# PortNode Record
node28:p0:s -> node40:n
node28:p1_0:s -> node7:n
node28 [label="{Record|{<p0>Name|{Elements|{<p1_0>1}}}}"]
...
# DeclarationLiteral rec
node40 [shape=box style=filled label="rec" fillcolor="#cccccc"]
...
}
Question: Divide the set of vertices of the graph in Problem 1 into strongly connected components
(SCC). Namely, specify which vertices are in the first strongly connected component, which
in the second, and so on.
is any one able to confirm ive done this correctly? namely when i reach vertex 4 i have the option to make the first SCC either 1,7,2,4,3 (as shown) or 1,7,2,4,6,5 depending on which way i choose to travel. Is there a method to this, or can i simply just choose?
order:
1,2,7,3,4,5,8,6
SCC:
1,7,2,4,3
5
8
6
The strongly connected component is {1,2,3,4,5,6,7}. If you don't get that, your algorithm (or your implementation) has a bug. There is a definition of Strongly Connected Component, and several well-known algorithms; both can be found easily in Wikipedia (and many other internet resources) and, most likely, in your textbook and/or course notes. (If you don't have course notes, you'll easily find some for similar courses.)
you can add 5 and 6 to 1,7,2,4,3 since both are reachable from others via 4
In DFS
you have to continue visting node and creating tree while the stack is not empty
if so, then restsrt with the lowest id which is still white
I'm currently looking for a solution to the following problem.
I need to be able to draw a hierarchical tree (e.g., syntax tree, which is basically a graph) over a table or other alignable component in an Eclipse RCP view. The cells of the topmost row in the table act as leafs. Consider the following simplistic example:
S
/ \
/ \
N VP
| / \
| V NP
| | / \
| | D N
| | | |
-------------------
WORD|John|hit|the|ball|
CAT.| N | V | D | N |
The sentence that is being analysed, and the analysis values themselves, are in a table, but could possibly be placed in any other alignable element.
Now I want to draw a tree above the table. For this I want to use a framework that provides layout algorithms. The trees will be bigger in reality, and I want to be able to provide automated layouting. By "automated layouting" I don't mean different "graph styles" (the graph/tree will always be horizontal and generally more or less "styled" like in the example) but the possibility to order the nodes and edges so that they don't overlap too badly, etc. (highlighting portions of the tree/graph would be nice as well).
Zest of course comes to mind (seeing that those trees are basically graphs), but as far as I've found out it isn't possible to "bind" edges to table cells.
Would something like this be possible in GEF?
Do you know of other frameworks that might be able to achieve such an outcome?
Other ideas, perhaps without using a table?
Many thanks!
I will use the GEF (MVC) plug-in rather than Zest after all, as it is easy enough to achieve something that looks like a table for a number of a certain type of Figure, while the tree can be drawn with different types of Figures.