Re: [eclipse-clp-users] Modifying node attributes in lib(graphviz)

From: Joachim Schimpf <joachim.schimpf_at_infotech.monash.edu.au>
Date: Tue, 14 Apr 2009 12:20:46 +1000
Justin W wrote:
> The following is sample code for modifying node attributes when visualising a graph using lib(graphviz).
> 
> 
> node_colour(Graph, Node, Attrs) :-
> 	( Node = 1 -> Attrs = [color=red] ; true ).
> 
> ?- make_random_graph(5, 10, true, true, true, G), 
>    view_graph(G, [node_attrs_generator:node_colour]).
> 
> 
> 
> Attrs is a list of Name=Value pairs that specify the attributes of the node.
> The list of attributes can be found at the following website:
> http://www.graphviz.org/doc/info/attrs.html
> 
> So for example, the following is valid and works perfectly fine:
> Attrs = [color=red, height=1.00, label=node1]
> 
> and the corresponding line in the dot file generated by Eclipse:
> 1 [label=node1, color=red, height="1.00", pos="63,108", width="0.75"];
> 
> The problem I have is specifying the pos, or coordinate attribute of the node, which is of type point.
> http://www.graphviz.org/doc/info/attrs.html#d:pos
> http://www.graphviz.org/doc/info/attrs.html#k:point
> 
> I've tried all of the following, and either I error out, or the position attribute isn't biting.
> Attrs = [pos="1,1"]
> Attrs = [pos='1,1']
> Attrs = [pos=1,1]
> Attrs = [pos=[1,1]]
> Attrs = [pos=[](1,1)]
> Attrs = [pos=(1,1)]
> 
> 
> Any help?
> 
> Regards,
> Justin


Hi Justin,

the Attrs = [pos="1,1"] syntax is the right one.

The reason you see no effect is that the layout program will override
your explicit positioning.  You can bypass the layout step by using
the [layout:none] option, but be aware that you then have to supply
*all* the layout information yourself!

Cheers,
Joachim
Received on Tue Apr 14 2009 - 02:20:55 CEST

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET