Graphviz Issue Tracker
Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0002544graphvizGraph Librariespublic2015-05-12 18:072015-05-26 15:54
Assigned To 
PlatformMacOSMac OSOS Version10.9.5
Summary0002544: The "page" (and the "pos"?) attribute of a graph does not apply
DescriptionFirst, I am using graphviz C library, in version 2.36 (installed using the .pkg downloaded form the website).
So I am working on the evolution of a graph and thus, I plot several observations of the same graph (with different edges, length of edges, but same nodes).
I want to plot them in a large page (same size for all), so that the distances are preserved and comparable. So I wanted to set the "page" attribute to a very large value (to make sure all graphs would fit on it), but this setting is not accounted for in the pdf generated.
For instance, I use:
agsafeset(g, "page", "8000,5000!", "");

which should create a very large file, but even with a simple small graph (see uploaded file), the graph fills the space.
It worked fine with the 2.30 version I had before...

As for the "pos" attribute, I set the first node (nodes[0]) at "0,0", even tried with "0,0!", but this node is never in the middle of the graph...
Here is the simple C code I tried it with:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cgraph.h>
#include <cdt.h>
#include <gvc.h>

int main()
    Agraph_t *g;
    Agnode_t *nodes[5];
    Agedge_t *e[4];
    GVC_t* gvc = gvContext();
    g = agopen("Graphe", Agstrictundirected, NULL);
    agsafeset(g, "page", "32,20!", "");
    agsafeset(g, "center", "true", "");
    int j;
    char nomNoeud[10];
    for (j = 0; j < 5; j++)
        sprintf(nomNoeud,"Node %d", j+1);
        nodes[j] = agnode(g, nomNoeud, TRUE);
    agsafeset(nodes[0], "root", "true", "");
    agsafeset(nodes[0], "pin", "true", "");
    agsafeset(nodes[0], "pos", "0,0!", "");
    e[0] = agedge(g, nodes[0], nodes[1], 0, 1);
    agsafeset(e[0], "len", "5", "");
    e[1] = agedge(g, nodes[0], nodes[2], 0, 1);
    agsafeset(e[1], "len", "3", "");
    e[2] = agedge(g, nodes[3], nodes[1], 0, 1);
    agsafeset(e[2], "len", "1", "");
    e[3] = agedge(g, nodes[4], nodes[1], 0, 1);
    agsafeset(e[3], "len", "10", "");
    gvLayout (gvc, g, "neato");
    char FileName[30];
    sprintf(FileName, "Test.pdf");
    gvRenderFilename (gvc, g, "pdf", FileName);
    //agwrite(g, stdout);
    gvFreeLayout(gvc, g);

Which results in this graph:
strict graph Graphe {
         graph [center=true,
         node [label="\N"];
         "Node 1" [pin=true,
         "Node 1" -- "Node 2" [len=5];
         "Node 1" -- "Node 3" [len=3];
         "Node 4" -- "Node 2" [len=1];
         "Node 5" -- "Node 2" [len=10];

I tried with a .ps output as advised by erg on the forum, but I cannot open the file with Mac's Preview or Adobe Photoshop/Illustrator...
Though outputting to text form and then using command line neato generates strange drawings: neato -Tps -o
The picture does not always contain the whole graph (even considering all the pages if the page size is smaller than the graph).

In short, in the .dot file, changing the "page" attribute of the graph changes the output picture (with some drawing issues), but does not change the output picture in the C code (using .pdf output, since I cannot open the outputted .ps files and using the "page" attribute did work with 2.30 before I updated it to 2.36).
Attached Filespdf file icon Test.pdf (Attachment missing)
dot file icon (Attachment missing)

- Relationships

-  Notes
User avatar (0000940)
erg (administrator)
2015-05-20 11:31

I will need to check on this, but the short answer is that the page attribute is mainly used to split a large drawing into multiple small pages, and even if you position a node at (0,0) and use center=true, this will not put the node in the center. Centering is done based on the bounding box of the drawing. If this worked in 2.30, it must have been an accident or a bug.

To get what you want, try using the viewport attribute. You can specify which node should be at the center of the drawing and the full size of the output.
User avatar (0000942)
damnegy (reporter)
2015-05-26 15:54

Hello erg,

Thank you very much for the help, I will try this!

- Issue History
Date Modified Username Field Change
2015-05-12 18:07 damnegy New Issue
2015-05-12 18:07 damnegy File Added: Test.pdf
2015-05-13 17:33 damnegy File Added:
2015-05-13 17:34 damnegy Tag Attached: page
2015-05-20 11:31 erg Note Added: 0000940
2015-05-26 15:54 damnegy Note Added: 0000942

MantisBT 1.2.5[^]
Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker