AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
xmlGraph (String graph) yoix.graph
 
Returns an Graph by parsing the supplied graph argument, which should be in the XML graph description format used by Yoix.
 
 Example:   The following script loads a graph in XML format from a string and writes in to standard output in dot format.
import yoix.graph.*;

graph_str = "\
<\graph name=g directed=1 strict=1 label=Example>\n\
    <graph_attributes color=white />\n\
    <node_attributes color=blue />\n\
    <node name=node_0 color=red />\n\
    <node name=node_1 />\n\
    <node name=node_2 color=green />\n\
    <node name=node_3 />\n\
    <node name=node_4 color=orange />\n\
    <edge name=edge_3_0 tail=node_3 head=node_0 color=yellow />\n\
    <edge name=edge_0_2 tail=node_0 head=node_2 color=green />\n\
    <edge name=edge_2_0 tail=node_2 head=node_0 color=red />\n\
    <edge name=edge_1_2 tail=node_1 head=node_2 color=blue />\n\
    <subgraph name=subg_0>\n\
        <edge name=edge_4_0 tail=node_4 head=node_0 color=red />\n\
        <edge name=edge_1_4 tail=node_1 head=node_4 color=blue />\n\
    </subgraph>\n\
</graph>\n\
";

g = xmlGraph(graph_str);

stdout.nextbuf = g.text(DOT);
The results on standard output are:
strict digraph g {
    graph [
        color=white,
        label=example
    ];
    node [
        color=blue
    ];
    node_0 [
        color=red
    ];
    node_1;
    node_2 [
        color=green
    ];
    node_3;
    node_4 [
        color=orange
    ];
    node_3 -> node_0 [
        name=edge_3_0,
        color=yellow
    ];
    node_0 -> node_2 [
        name=edge_0_2,
        color=green
    ];
    node_2 -> node_0 [
        name=edge_2_0,
        color=red
    ];
    node_1 -> node_2 [
        name=edge_1_2,
        color=blue
    ];
    subgraph subg_0 {
        node_4 -> node_0 [
            name=edge_4_0,
            color=red
        ];
        node_1 -> node_4 [
            name=edge_1_4,
            color=blue
        ];
    }
}
 
 Return:   Graph
 
 See Also:   countElements, Edge, Graph, listElements, Node

 

Yoix is a registered trademark of AT&T Inc.