DOTGraphTraits and GraphWriter

Hi all,

I have two questions related to .dot graph output. Basically, I have a
graph representing a program dependence graph like structure with
(a) multiple edges between the same pair of nodes
(b) each edge having a special (different) text/label

I implemented a template-specialized version of DotGraphTraits for the
my graph structure which given a node, uses a map_iterator (similar to
the one used in CallGraph) to get the destination node of an outgoing
edge. This works fine except that I have no clue how to support (a)
and (b) since once the destination node is returned I lose access to
the edge and cannot do any text annotation onto an edge of the graph.

Is there some other way to achieve (a) and (b) without having to
implement my own special version of GraphWriter ?

thanks,
Prakash

Hello Prakash,

The SelectionDAG viewers (llc -view-isel-dags etc.) support
both multiple edges between the same pair of nodes, and labels
at least for each incoming edge. See
lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp for code you
might use as an example, though it is a bit tricky.

Dan

Hi Dan,

Thanks for the reply. I got the labels for each outgoing edge (at the
source node's 'structure' field) working. Is there a way to find out
the outgoing edge number from EdgeIter. (Basically the Node in my
graph has a a bunch of outgoing edges, so that I can just index into
that collection within the node to get the appropriate edges'
attributes).

regards,
Prakash

Hi Prakash,

I don't know of an easy way to do this, other than to use random-access
iterators so you can compute the distance between the edge and the
beginning of the list of edges.

Dan

Hi Dan,

I remodelled my graph to have more information from the source node
field of each outgoing edge rather than an edge itself, so now I no
longer need to use EdgeIter specfically. Thanks!

- Prakash