Xref: utzoo comp.sources.wanted:13373 comp.text:7268 Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!samsung!munnari.oz.au!mel.dit.csiro.au!yarra!bacchus!matt From: matt@bacchus.esa.oz (Matt Atterbury) Newsgroups: comp.sources.wanted,aus.wanted,comp.text Subject: Re: Hierarchical structure -> graphical representation (c.f. GPIC/GTROFF) Message-ID: Date: 24 Sep 90 01:46:14 GMT References: <1990Sep22.032404.20089@brolga.cc.uq.oz.au> Sender: matt@bacchus.esa.oz Distribution: comp Organization: Expert Solutions Australia. Lines: 54 In-reply-to: exnirad@brolga.cc.uq.oz.au's message of 22 Sep 90 03:24:04 GMT In article <1990Sep22.032404.20089@brolga.cc.uq.oz.au> exnirad@brolga.cc.uq.oz.au (Nirad Sharma) writes: I wish to translate a c representation of a hierarchical structure i.e. struct info { ...attributes... struct info *children, *sibling } into PIC statements that will generate visually balanced trees i.e. o / \ o o / | \ o o o I have a program that takes a file of format: tree ::= node node ::= name subtree subtree ::= | '(' { node } ')' (well, one a bit more specific than that, but you get the idea). It doesn't handle digraphs, just trees (what is the `|` in your pic?). It doesn't produce PIC output, just ASCII chars. eg. A A ( / \ B / \ C B C ( -> / \ D / \ E D E ) ) It is for drawing JSD entity-action diagrams, but it should be reasonably easy to modify. It has a number of stages: parse input file to build internal representation layout text for each node using a heuristic position each node within the whole tree - (x,y) of T/L corners draw tree (using + - | ' ' for line drawing and positioning). I would expect that it wouldn't be too hard to hack for your purpose. The hard part is positioning each node. I believe my algorithm is correct (it has worked fine so far). Interested? I have posted in case anyone else is also interested, since this is a classical example of something that shouldn't have to be re-invented by everyone! -- ------------------------------------------------------------------------------- Matt Atterbury [matt@bacchus.esa.oz] Expert Solutions Australia, Melbourne UUCP: ...!uunet!munnari!matt@bacchus.esa.oz "klaatu barada nikto" ARPA: matt%bacchus.esa.oz.AU@uunet.UU.NET "life? don't talk to me about life!"