How would I force the order of clusters in Graphviz? For example, I have three clusters: inputs, processes, outputs. I want to ensure that the clusters are in the diagram in that order from leaft to right, then in each cluster I don't really care which order they appear or layout used.
There seems to be no easy fix to the problem of positioning clusters. (see How do I get individual clusters on 3 different levels?)
If invisible edges don't work for your graph (sometimes they do and sometimes not), look at gvpack (https://graphviz.org/pdf/gvpack.1.pdf). This program lets you create the 3 "clusters" as independent graphs and then will allow you to pack (glue) the three graphs into one graph.
Related
For quite some time now, I've been hacking away at this problem but never have managed to come up with an entirely satisfactory solution. It concerns network flow - where you have a graph of nodes which are imagined to have some kind of resource flowing between them, like water in pipes, or traffic on a road system, and so forth.
Such network flow problems seem to be usually given in terms of three types of nodes only: sources (i.e. resource is generated or at least emplaced into the network there), routers or junctions (splits or combines resource conservatively), and sinks (consumes, disposes, etc. of resource). And then we do something like ask how we can solve for the flows on the edges so as to try and figure out the best way to use what is available from the sources to meet the demand from the sinks, i.e. to compute the maximum flow.
But what I am interested in is how you deal with this when you add a fourth component into the mix: tanks, or parts which can "fill up" with resource to later discharge it. From the perspective of the network and depending on the amount of resource they contain, they can seemingly act like all three of the other components depending on their capacity and how they are hooked up - note that a tank can both have things feeding it and things drawing from it simultaneously, or have only feeders or only draws, so it can act in all three roles above. Moreover, depending on whether it contains content or empty space, it can likewise also change role - an empty tank cannot act as a source, obviously, nor can a full tank act as a sink, as it can't fit any more stuff into it.
For example, if the flow solver is given something like this:
then it should put a rate of 50 units/sec of flow on the left edge, 5 units/sec on the right edge, because the tank can absorb 45 units/sec.
But if the tank is hooked like this:
then the solver should put 45 units on the vertical edge as flowing out from the tank, and 5 units flowing from the source, to meet the total demand of 50 from the sink.
That is, in a graph involving a tank, the tank should "supplement" flow provided from sources to meet demand from sinks, or else should "absorb" excess flow that did not have corresponding demand. However, it must only do this while respecting what it can reach or what can reach it from the connections provided by the edges. Note here my drawings are perhaps oversimplified as they ignore the edge directions, but the intent is that the edge leading up from the tank in the second one is directed into the junction. Thus, the behavior in a different case where the source were to advertise +50 and the sink -5 should just be to route 5 U/s from the source to the sink, i.e. the usual max-flow, and the tank would not contribute any flow. If it had a bidirectional edge, then in this case it should absorb 45 U/s from the source, while in the original case behaving no different from the unidirectional case.
How can one create an algorithm to reliably generate such solutions, given only the graph and which nodes are tanks, junctions, sources, and sinks and what the supply from the sources and demand from the sinks are?
If you assume that your tanks have infinite capacity ( they can absorb an infinite quantity at the 'produce' rate AND be drawn down for an infinite quantity at the 'consume' rate, then you can solve the problem using normal graph flow algorithms.
If the tanks have finite capacity, i.e. they change their behavior when they run dry or become full, then the solution changes with time and times depend on the initial levels of the tank. If the tank capacities are large relative to the flow rates, the solutions will be steady state for significant periods. So you create multiple graphs, representing every possible combination of the three tanks states ( full, empty, or partial ) for each tank and solve each using graph theory. This will only be feasible if the number of tanks is modest.
If you have many tanks, and you are interested in the time behavior of your system. you will have to use a simulation approach.
There are many generic simulation packages available that can be configured to solve this problem. The challenge is to interpret the results, a task which requires good understanding of statistics.
You might also consider coding your own special purpose simulator. You do not mention your preferred coding language, but if you know C++ you can get a good start from https://github.com/JamesBremner/tankfill
I have an existing system model, representing services calling APIs backed by one or more implementations in perhaps other services, in the form of a DAG. I've been rendering this by GraphViz dot files' digraph which is fairly reasonable, if sometimes difficult to enforce layering.
While considering various possible refactorings of services and APIs, I'd like to be able to chart alternative routes towards an end goal. Each refactoring step would yield a different DAG – represented in terms of diffs from the previous DAG (e.g., convert service A's use of API x in service B to API y in service C) – and similarly renderable.
What tools are there to be able to create such "refactoring paths" and then visualize flows between them, determine dependencies and parallelism? Extra bonus points for goal seeking (e.g., no dependencies from any service other than service A on service C; cheapest path based on weights) and providing a loose ordering of refactorings that demonstrate their (presumably) monotonically increasing system value.
I am picturing two UI components:
a DAG diff that shows visually the nodes/vectors that got replaced in the source graph with nodes/vectors in the second
a controlling display that acts like D3's force layout that lets you navigate the loosely connected DAG of refactorings and select which refactoring you'd like to see the before/after picture in the DAG diff.
That said, I'm totally up to other tooling, formats, etc. Just would like to be able to produce these and display them to other people as to why what we're doing is valuable (goal assertion) and taking as long as it does (dependencies and Gantt charts).
Would it be feasible for you to create a separate tool that, given two similar DAGs, outputs the "merge" of them? If that's possible, then visualizing the merge DAG will probably tell you a lot about both DAGs. You can color-code the nodes by whether they appear in both DAGs or in either.
That's how we originally designed the visual diffs of workflow graphs in VisTrails, see here.
If you insist on showing the two DAGs side by side, creating the merge DAG might still be the right idea, because then dot can lay the merge graph out, and you can simply hide the appropriate nodes for each subgraph. In this way, the shared structure will be laid out consistently by construction.
I have a circular grid of ~2700 cells that represent the face of a detector. This grid is live, constantly updating, so we need to find clusters of hits with a couple microseconds.
Each cell is either a hit or a miss (0 or 1), and a cluster is a grouping of these hit cells that has a distinct perimeter. I want to count the number of clusters of hit cells very quickly so that we can save the data from events with a certain number of clusters (2) and toss out everything else.
Some algorithms currently in use rely on assigning a value for the number of hit neighbors to the cell. This is too slow because it requires all of the hit crystals to be identified before the clusters may be identified. Another, much prettier algorithm that works in parallel is based on the number of turns around a given perimeter of a cluster. It's really quite clever, so here's the link to the paper: http://www.sciencedirect.com/science/article/pii/0168900295007997 This paper also has an image of an ideal grid with clusters.
Most of the posts / papers I've read take data and apply markov chains or some other offline processing to create clusters of data-- we're looking for the opposite. We want to identify clusters of cells that we already have, and fast.
How might we find these clusters faster? Any tips or ideas to put me in the right (or a) direction?
Thank you!
For nodes, there is nodesep which increases space between nodes. Is there such an attribute for subgraph cluster?
I already tried to do this before. According to this link http://lists.research.att.com/pipermail/graphviz-devel/2009/000947.html, it seems that there is no current solution to the problem.
However, a little "hack" consists in surrounding your cluster with a chosen number of invisible clusters. In fact, the clusters have a small margin that can't be altered, but nesting them and hiding the border simulates a custom margin.
Another possible hack if you're not using rank as an attribute, set rank=same within each cluster and then add a ranksep=K, where K is some factor you want to separate by. Worked nicely for me.
I set the margin option within each cluster. Though this does not separate the clusters, it add space between the nearest nodes, which may be sufficient for you, especially if you are using style=invis.
Are there any recommended algorithms for placing circuitry?
Restrictions:
Only perfectly vertical/horizontal lines
Can cross at right-angles, but can't run over one another in parallel.
Input:
A set of input points with output points defined. These points have a radius in which no other circuit wire can pass, except for the one going to it.
A bit left field, but check out the open source Graphviz tool. It uses some kind of spring like algorithm from memory to place nodes without overlapping connections. Not sure how suitable it would be for circuitry though: http://www.graphviz.org/Gallery/twopi/twopi2.html