[Graph Libraries] The "page" (and the "pos"?) attribute of a graph does not apply
Ported Issue from Mantis Original ID: 2544 Reported By: damnegy
SEVERITY: MINOR Submitted: 2015-05-12 23:07:31
OS: MAC OS
OS BUILD: 10.9.5
PLATFORM: MAC
DESCRIPTION
First, 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);
agclose(g);
}
Which results in this graph:
strict graph Graphe {
graph [center=true,
page="32,20"
];
node [label="\N"];
"Node 1" [pin=true,
pos="0,0!",
root=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 simple.dot -Tps -o Simpletest.ps
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).