Graphviz DOT arrange Nodes in circles, layout too "compact" - layout

I'm halfway there please see the edit
OK here's my problem, I'm generating a graph of a python module, including all the files with their functions/methods/classes.
I want to arrange it so, that nodes gather in circles around their parent nodes, currently everything is on one gargantuan horizontal row, which makes the thing >50k pixels wide and also let's the svg converter fail(only renders about the half of the graph).
I went through the docs but couldn't find anything that seems to do the trick.
So the question is:
Is there a simple way to do this or do I have to layout the whole thing by myself? :/
EDIT:
Thanks to Andrews comment I've got the right layout, the only problem now is that it's a bit to "compact"... so the question now is, how to fix this?

i've mentioned all of the most significant parameters that influence your current layout and then suggested values for those parameters. Still, i suspect you can get the layout that you want just from applying a couple of these suggestions.
reduce the edge weight, eg, [weight=0.5]; this will make the
edges longer, causing the tight
clusters you currently see in your
graph to 'fan out'.
get rid of the node borders, node_A
[color=none; shape=plaintext];
especially for oval-shaped nodes, a
substantial fraction of the total
node space is 'unused' (ie, not used
to display the node label).
explicitly set the font size for
the nodes (the node borders are
enlarged so that they surround the
node text, which means that the font
size and amount of text for a given
node has a significant effect on its
size); [fontsize=11] should be large
enough to be legible yet also reduce
the 'cluttered' appearance (the
default size is 14).
increase minimum separation between
nodes, via 'nodesep'; eg, nodesep=2.0; this will
directly address your objection
regarding your graph being "too
compact." ('nodesep' and 'ranksep'
probably affect how dot draws a graph
more than any other parameters for
node, edge, or graph. In your case,
it looks like you have only two ranks
of nodes; 'ranksep' sets the minimum
distance between nodes of different
ranks--it looks like all of the nodes
that comprise your graph are of the
same rank (except for few top level
nodes in the centers).
explicitly set total graph size, eg,
size="7.75,10.25" (ensures that your
graph fits on an 8.5 x 11 page and
that it occupies the entire space)
And one purely aesthetic suggestion
that at most will only help your
graph appear less cluttered: the
default fontcolor for both edges and
nodes is black. The majority of the
ink on your graph is from those two
structures (particularly if you
remove the node borders), so i would
for instance set either the node
(text) fontcolor or the edge
fontcolor to "blue" to help the eye
distinguish the two sets of graph
structures.

If it is too compact, you will want to mess with the edge length. You have a couple options depending on the graph layout:
If your layout is sfdp or fdp, tweak the graph property K. Default is 0.3.
For neato (or fdp), tweak the edge property len. Default is 1.0 for neato and 0.3 for fdp.
For dot you can use the edge property minlen which is the minimum edge length. Default is 1.
You might also want to mess with the graph property model which determines clustering behavior. Specifically, try subset. I believe this handles len for you:
http://www.graphviz.org/doc/info/attrs.html#d:model
Also, you can remove overlaps all together with scaling techniques: http://www.graphviz.org/doc/info/attrs.html#d:overlap

I have around 500 nodes and used doug's recommendation.
This is my sample code that works (in python):
f = Digraph('companies',filename='companies.gv',
edge_attr={'weight':'1',
'fontsize':'11',
'fontcolor':'blue',
'len':'4'},
graph_attr={'fixedsize':'false',
'bgcolor':'transparent'},
node_attr={'fontsize':'11',
'shape':'plaintext',
'color':'none',
'fontcolor':'black'})
f.attr(layout="neato")
f.attr(nodesep='3')
f.attr(ranksep='3')
f.attr(size='5000,5000')

Related

Choosing graph layout: force-directed or Sugiyama or another

I have some data: items and their pairwise similarities.
When user selects item I want to give him some fancy representation of item's neighbors and their connections. It should be readable and easy to catch either common structure or details.
And I go to graphs -- graph communities, graph layouts.
So I have item's neighbors graph, 20-30 nodes. What's next?
Too many edges is a kind of noise, so I limit minimum valuable similarity and total count of edges.
I get graph communities (somehow, now it's fastgreedy). They will have different colors on my picture.
I should choose graph layout.
First thing I've tried is Fruchterman-Reingold.
fruchterman (I draw gray edge if nodes belong to different clusters.)
Maybe it's quite good, but I have some doubts. And I've tried layered layouts for trees: Sugiyama, Reingold-Tilford.
sugiyama
Is it better looking? But that case seems worse:
sugiyama2
So this is main question: what layout would be adequate?
And I hide labels, because it's unclear too: how to get them not to obstruct fancy edges, not to overlap, being easy for perception and etc.
Thank you!
Now I think that Reingold-Tilford (or Sugiyama) is pretty okay.
It's not okay when some community has too many edges -- I can easily detect it and just decrease number of edges.

How to increase polygens in 3dsmax

I am beginner in modelling. Can I increase object's polygen in 3dsmax? I want have smooth object that have not low polygens.
You can increase the polygon count of you model so many ways:
Use subdivide modifier.
Use the turbo smooth modifier.
Use tessellate modifier.
You can use TurboSmooth modifier for this purpose, but before use it, you should make sure your model have enough edges and check if the edges are correct. for example, make sure your vertex not connect to odd number edges( like 3 or 5 edges ) always try to keep it in even numbers, 4 edges is standard, check image below :
both of them used odd numbers ( 3 and 5 ) which is not correct.
try to add more edges to your model and Chamfer them if necessery, before applying turbosmooth or other smooth Modifier's.
You can smooth it by adding a smooth or turbo smooth modifier, then convert it to polygon edit again - or collapse the object class from modify tab - this will reproduce polygon evenly all over the object faces.
Alternately you can select a ring or loop of faces then use the connect tool to add more resolution (polygons) to these selected polygons only
As for the fish model in your image, you can select one of the height faces, then from the polygon edit section in the modify panel on the right, click ring it'll select all the height faces all around the fish, then scroll down on the modify panel click on connect and set the number to add more resolution
UPDATE:
Please take in consideration that there's nothing like infinite segments even spheres (balls) or cylinders in 3D just have a higher number of segments - usually 32+), you can double or triple it but not more, increasing objects segments for very high values can bring your computer down to its knees while modeling or rendering
New versions of 3dsmax (2015, 2016) have a new subdivision modifier called OpenSubDiv modifier. This can be used to subdivide your model, and give it more polygons. There is also the Turbosmooth, Meshsmooth, Tessellate, and Subdivide modifiers available. All of these will add more geometry to your model, based on different algorithms.

How do I check if a set of plane polygones create a watertight polyhedra

I am currently wondering if there is a common algorithm to check whether a set of plane polygones, not nescessarily triangles, contruct a watertight polyhedra. Each polygon has an oriantation (normal vector). A simple solution would just be to say yes or no. A more advanced version would be to point out the edges, where the polyhedron is "open". I am not really interesed on how to close to polyhedra.
I would like to point out, that my "holes" are not nescessarily small, e.g., one face of a cube might be missing. Thus, the "undersampling correction" algorithms dont seem to be the correct approach. Furthermore, I am talking of about 100 - 1000, not 1000000 polygons, so computation time should not really be a problem.
Any hints or tips?
kind regards,
curator
I believe you can use a simple topological test -- count the number of times each edge appears in the full list of polygons.
If the set of polygons define the surface of a closed volume, each edge should have count>=2, indicating that each edge is shared by (at least) two adjacent polygons. If the surface is manifold count==2 exactly.
Edges with count==1 indicate open regions of the surface.
The above answer does not cover many cases. A more correct (but not necessarily complete: I wouldn't know) algorithm is to ensure that every edge of every polygon (or of the mesh/polyhedron) has an even number of faces connected to it. Consider the following mesh:
The segment (line) between the closest vertex and the one below is attached to 3 faces (one one of the outer triangle and two of the inner triangle), which is greater than two faces. However this is clearly not closed.

SVG plot from point-value pairs

I need to write some code (for a web.py webapp with a straight-HTML/JS client) that will generate a visual representation of a set of point-values. Each point has an X and Y coordinate, and the value is an integer. If I can use SVG to do this, then I can scale the image client-side with no extra code. Can I actually do this? I am concerned about a couple of things:
The points don't necessarily have any relation to each other. They aren't necessarily in a grid, nor can we say how many points are nearby, etc.
Gradients are primarily one-direction, and multiple gradients on the same shape seems to be a foreign concept.
Fills require an existing image, at which point, I'd be better off generating the entire image server-side anyway.
Objects always have a layering, even if it isn't specified, which can change how the image is rendered.
If it helps, consider a situation where we have a point surrounded by 5 others, where one of them is a bit closer than the others (exact distances and sizes can be adjusted). All six of the points have different colors (Red, Green, Blue, Cyan, Magenta, Yellow, with red in the center and Yellow being slightly closer), and the outer five points are arranged roughly in a pentagon. Note that this situation is not the only option, just a theoretically possible situation.
Can I do this with SVG, or should I render an image server-side?
EDIT: The main difficulty isn't in drawing the points, it is in filling the space between the points so that there is no whitespace, and color transitions aren't harsh/unpredictable if you know the data.
I don't entirely understand the different issues you are having with wanting to use svg. I am currently using the set up you are describing to render X-Y scatter plots and gaussian curves and found that it works great.
Regarding the last point about object layering, you have to be particularly careful when layering objects with less than 100% opacity which are different colors. The way the colors "add" depends on the order in which you add the objects to your svg drawing.
Thankfully you can use different filters to overlay the colors without blending them. Specifically I am using the FeComposite filter element. There is a good example of its usage here:
http://www.w3.org/TR/SVG/filters.html#feCompositeElement

Bipartite Graph (undirected)

I am taking an input, e.g.
4
1 3
1 2
2 4
First line is number of nodes, lines after that are the edges. I have to attempt to color the graph, and if I can't, I need to list a cycle in the graph that is causing the error.
This is fine so far, except one of the graphs contains 1,000,000 nodes. Everytime I try to use it I get a Stack Overflow error, even though I streamlined it more, and raised the max heap size of eclipse to 1024m.
I'm not asking for code, just asking if I am doing something blatantly wrong to keep getting errors.
Maybe you could optimize your cycle detection algorithm.
This might help you: http://en.wikipedia.org/wiki/Cycle_detection
Other than that, a million nodes plus adjacency matrix might as well be too much to handle at once, so perhaps there's a way to just load parts of the graph at a time.
If it's a bipartite graph you can always colour it with only two colours (e.g. colour the first partition white, and the second partition black).
Usually when one thinks of colouring a graph he should specify the number of colours. You can always colour a graph by assigning to each node a different colour. Another example: for planar graphs only four colour are required. However, for most graphs the [chromatic number] of a graph is [NP].
[NP] http://en.wikipedia.org/wiki/Karp%27s_21_NP-complete_problems
[chromatic number] http://en.wikipedia.org/wiki/Graph_coloring
Well, this IS an NP complete problem (longest cycle), so this sort of thing IS likely to happen.
I'd probably just bump the heap again, and let it run...
EDIT: Never mind. got my reduction backwards.

Resources