s-news
[Top] [All Lists]

Re: Representation of tree graphs or branching structures.

To: s-news@lists.biostat.wustl.edu
Subject: Re: Representation of tree graphs or branching structures.
From: juhlin.kd@pg.com
Date: Tue, 16 Dec 2003 08:34:38 -0500
Pgsenderhost: bdc-notes041.na.pg.com [155.125.116.41]
Lina,
I've sent you a message privately on this, but forgot to copy the S news list.
The best software I've found is Graphviz, available at

http://www.research.att.com/sw/tools/graphviz/

It does directed graphs (including trees and DAG's), and a version of it 
(called neato) does undirected graphs.
The documentation is very clear and the scripting language is a marvel of 
simplicity.

To use the program, you just need to write a little S-Plus script that takes 
your data structure and creates text strings that represent
 the Graphviz input code (this is much simpler than it sounds, once you see the 
graphviz scripting language).  This requires one pass through your dataset.
For example, your dataset below can be translated into the following script:

digraph sample
{
1 -> 2;
2 -> 3;
2 -> 6;
6 -> 7;
7 -> 11;
11 -> 5;
}

so the translation of your dataset to graphviz code is straighforward.  By
running the above program in graphviz (the exe program called dot)  you get
exactly what you need.  With this stripped-down example, the nodes will be
labeled 1,2,3, etc., but you can add code to change the labels, colors, node
shapes, and you can add labels to the edges.  I use the Windows (DOS) version
but there are UNIX versions too.

- Kenton


west@codingstrand.com wrote:

> Dear list members:
>
>
>
> Does anyone know if it is possible to graphically render a branching
> tree like structure in SPlus?  i.e. I have a data frame with 3 columns
> as follows:
>
>
>
> Index     Node1     Node2
>
> 1         1         2
>
> 2         2         3
>
> 3         2         6
>
> 4         6         7
>
> 5         7         11
>
> 6         11        5
>
>
>
> I would like a pictorial(line?) representation of the connections
> between Nodes1 and Nodes2 as I work down the sheet by Index.
>
> Is this possible, and if not can someone reccommend a suitable
> alternative if possible?
>
>
>
> Thanks for any help or suggestions.
>
>
>
> Lina


There are functions in S Poetry (available via a "shar" file)
for mathematical graphs.  This includes a plot method.
I'm a bit dubious that it will satisfy your needs, but it may
be a starting point.

Patrick Burns

Burns Statistics
patrick@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")

west@codingstrand.com wrote:

Dear list members:

 

Does anyone know if it is possible to graphically render a branching tree like structure in SPlus?  i.e. I have a data frame with 3 columns as follows:

 

Index     Node1     Node2

1         1         2

2         2         3

3         2         6

4         6         7

5         7         11

6         11        5

 

I would like a pictorial(line?) representation of the connections between Nodes1 and Nodes2 as I work down the sheet by Index.

Is this possible, and if not can someone reccommend a suitable alternative if possible?

 

Thanks for any help or suggestions.

 

Lina

<Prev in Thread] Current Thread [Next in Thread>