Dynamically creating a force directed graph with weighting - graph

I can't find any way to draw a force directed graph where the weighting of the edges affects their length.
Although the Neato layout engine for .Dot format claims to do this, it never seems to actually respond to the edge weight that I give to it.
Ideally, I'd like to do this in Javascript. I've been using the Javascript Infovis Toolkit, but this doesn't seem to have any means for setting a weighting.
Any suggestions gratefully received!

So infovis doesn't solve this problem at all well, and I can't see what's going on with gvis either. However, I have solved this problem using cytoscape.
Although I haven't used it, cytoscape does have a command line option, so you could potentially use it to create images dynamically.

Related

cytoscape: Dagre-layout prevent nodes from laying on edges

I am using cytoscapejs with dagre layout (https://github.com/cytoscape/cytoscape.js-dagre). I am very happy with this extension, however, there is one problem I am struggling with. In particular, I would like to prevent that nodes are allowed to lay over edges. Because of that, there are some examples where one cannot distinguish between an edge from a node to a successor and an edge from the successor of the particular node to the succeeding node. There is also an open issue regarding this misbehavior (https://github.com/cytoscape/cytoscape.js/issues/1078)
I allready tried out other curve-style layouts such as 'segments' and 'haystack' but unfortunately without success.
Does anyone of you have an idea how to do that?
Thanks in advance
Andy
You'd have to convert the points that Dagre gives you into segment values. You could put those values in .scratch() to be used in a mapper.
See https://github.com/cytoscape/cytoscape.js-dagre/issues/5
There are a lot of things in the queue for Cytoscape and the extensions, but unfortunately time and resources are constrained and this feature request is relatively low priority. You're welcome to make a pull request on the extension if you'd like to use the feature.
Thanks

Is there any method for fix manually an Alloy Analyzer graph?

I need to fix my Alloy graph, for example I have this output:
I can't move "node2" rectangle over the row of "node0" and "node1", and I can't move "node1" under "node2" whitout also move "node0". Is there any solution? Thank you.
PS: I am using Alloy Analyzer 4.2 under Windows.
PPS: This is only an example, i get a big graph with 5 or 6 rows of 20-25 rectangles, and if I can't fix it manually, it's only a mess.
To answer the direct question: I for one have never found a way to make the visualizer change its mind about which nodes should be on the same horizontal level. (That doesn't quite mean it's not possible, but it does mean that if it's possible it's not immediately obvious how to do it. But I guess you knew that already.)
If your goal is to make the auto-generated diagrams easier to read, the simplest approach is to experiment with adjustments to the visualizer theme. The "Magic Layout" button can be helpful; manual adjustments to hide some nodes or display some relations as labels rather than arcs can help with diagrams which are otherwise too cluttered.
If your goal is to make a 'good' version of a diagram for inclusion on a slide for a talk or a figure for a paper, you may want to export to Dot and import into a graph-drawing tool that gives you the kind of manual control you want (or edit the .dot file yourself, if you are familiar with graphviz and can make it do what you want), or export to XML and generate the graph description language of your choice from the XML.
I hope this helps.
The Lightning tool is an Ecplise plugin relying on Alloy4.2 to formally define Domain Specific Languages and might be a solution to your problem.
It's still under development, but if you are only interested in being able to freely reorganize each atom and label of generated instances, there shouldn't be any problems, as it uses Ecplise draw2D to render those latter.
If now you're really interested in providing an intuitive visualization to your generated instance (by intuitive I mean a visualization that is closer to its domain rather than the structure of your model), then you can define your own language (with your model as abstract syntax ) and define a concrete syntax for it.
The update site to be used for the installation of the tool is : http://lightning.gforge.uni.lu/update-site
Don't hesitate to contact me if you plan to give it a shot and get any issues.
(I'm eager of constructive feedbacks ;-) )
The steps to follow to generate a graphical instance in which any components can be moved are :
Install Lightning
Create a new Lightning Project
Create a new Language in this project
Put your model in the ASM folder
generate instances of the language by "running the project"

What does IDA use for graphing?

We need to create a CFG for some custom intermediate language code. We are currently using Qt + graphviz - and the CFGs look like ass.
Specifically, we cant seem to figure out how we can
get the "flow" (from top to bottom) into the graph, and
make the connecting lines go AROUND the other graph nodes.
Anyways, we were admiring the awesome IDA CFGs - and noticed that IDA does not seem to use graphviz at all! GV adds x MB of dependencies to our project, and we'd love to get rid of it.
SO the questions is: does anyone know what IDA uses for graph rendering and sorting?
We considered writing a IDA plugin to use the graphing feature, but that seems a little over the top for what we want to do.
Last I Checked they used (Q)WinGraph, you can get their modified source from this page (based off of VCG tool).
Something similar is yED which you might also want to check out & there are a few IDA scripts that use TouchGraph as well (which doesn't seem to be free).
I think that IDA use its own graph library (although you might ask Ilfak Guilfanov for a definitive answer about that).
What you're looking for is called "Sugiyama graph layout algorithm" (see: Layered graph drawing).
There is a really interesting paper about this problem (especially focusing on CFG) on citeseerx (see: Graph Layout for Code Flow Visualization).
As stated in the aforementioned paper the OGDF provides a Sugiyama layout algorithm although it might require some tweaking.
Hope that helps !

How to do chalk style drawing with Qt

I want to use Qt to draw lines in chalk style, as you typically see on a blackboard. Here is an example of what I have in mind:
What is the best way to achieve this rendering style? Do I need to draw a lot of little lines with a special brush, or is there a better way to get the "curvy" style you see in the sample image?
And where is the best place to integrate this? Theoretically it would be ideal to get this underneath QPainter, e.g. in a custom QPaintEngine, so that e.g. all the various QPainter::drawLine calls end up using the chalk style. However, it seems while the QPaintEngine interface looks perfect for this, the class itself isn't meant to be used for this purpose...
Thanks in advance for any help.
Greetings,
Fabian
I have solved the problem in a different way. Using textured brushes didn't provide good results (maybe my fault). QGraphicsEffect was unfortunately not an option since my rendering is not based on QGraphicsView.
What I have done in the end:
Derived an own class from QPainter (i.e. ChalkPainter)
Added a new drawChalkLine() method to ChalkPainter. This method takes the passed line, splits it into smaller chunks and renders these chunks as bezier curves via QPainter::drawPath. For each bezier curve chunk I randomly shift the control point orthogonal to the line.
Next I added additional rendering methods to the ChalkPainter class, such as drawChalkRect(), all internally using the drawChalkLine() method.
This is not the most elegant method since I can't use the QPainter methods directly, but it provides good results for my purpose. Here is an example:
I would start looking in QGraphicsEffect's way.. I think it should be possible to develop such a filter which will produce similar effect..
I'll update in here answer on your comment.
No, QGraphicsEffect can be applied 'per graphics item'. If you have a look on QGraphicsItem you will see that there is a setGraphicsEffect method, so you can design an effect which works on QGraphicsLineItem for example and set it only on lines you want to look chalky..
Important thing is that you don't have to operate on pre-drawn image, you can either make it completely owner-draw item with graphicsEffect (for example make an assumption that effect is only applicable on QGraphicsLineItem) pre-draw it using drawSource() and then modify OR draw it completely from scratch..
I would love to help you with some coding, probably will do it somewhere around next week, since I will need similar thing for project I am working on now.. but physically don't have time next few days..
I'll update an answer with sources link as soon as it's done.
Custom brush also looks really promising..

What tool is this - or anyone got an alternative tool

I need to make a very simple drawing of a graph (NOT a chart but a graph, like in Dijkstra) with multiple nodes and multiple vertexes.
I once saw this guy using a tool where he wrote the data in notepad then compiled or something and then he had an svg to view in a browser - to me this should be the simplest tool to draw this graph in. Anyone know what this tool is? Or know a simple, open source/free tool to make simple graphes (need to be able to automatically rearrange it so it looks decent)
Cheers,
Try Graphviz:
http://www.graphviz.org/

Resources