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
Element typedict
 
A variable that is declared to be an Element accepts any graph object value, namely Graph, Node, or Edge, and its type corresponds to the type of that value. Uninitialized Element variables, no matter where they happen to be declared, always start as NULL.
 
 Example:   The program,
import yoix.stdio.*;
import yoix.type.*;

Element  e1;
Element  e2 = new Graph { String name = "g"; };
Element  e3 = new Node { String name = "n"; Graph parent = e2; };
Element  e4 = new Edge {
    String name = "e";
    Node tail = e3;
    Node head = e3;
    Graph parent = e2;
};

type(e) {

    if (e == NULL)
	return(toString(e));
    else if (isNode(e))
	return("Node");
    else if (isEdge(e))
	return("Edge");
    else if (isGraph(e))
	return("Graph");

    return("ERROR!");
}

printf("e1=%s, e2=%s, e3=%s, e4=%s\n",
       type(e1), type(e2), type(e3), type(e4));
e1 = e2;
e2 = e3;
e3 = e4;
e4 = NULL;
printf("e1=%s, e2=%s, e3=%s, e4=%s\n",
       type(e1), type(e2), type(e3), type(e4));
printf("The graph is:\n%sor:\n%s",
       e1.text(), e1.text(yoix.graph.DOT));
prints
e1=NULL:Element, e2=Graph, e3=Node, e4=Edge
e1=Graph, e2=Node, e3=Edge, e4=NULL:Element
The graph is:
<graph name=g>
    <node name=n />
    <edge name=e tail=n head=n />
</graph>
or:
graph g {
    n;
    n -- n;
}
on standard output.
 
 See Also:   Edge, Graph, isEdge, isNode, isGraph, Node, xmlGraph

 

Yoix is a registered trademark of AT&T Inc.