Friday, December 3, 2010

Dot Language

One of the best softwares to keep a tidy tab on the graphs is the graphviz. Useful in writing customized digraphs and not fall back on paint and other drawing tools. It utilizes special DOT language syntax which is intuitive.




Dot language:-

graph → [strict] (digraph | graph) id ’{’ stmt-list ’}’
stmt-list → [stmt [’;’] [stmt-list ] ]
stmt → attr-stmt | node-stmt | edge-stmt | subgraph | id ’=’ id
attr-stmt → (graph | node | edge) attr-list
attr-list → ’[’ [a-list ] ’]’ [attr-list]
a-list → id ’=’ id [’,’] [a-list]
node-stmt → node-id [attr-list]
node-id → id [port]
port → port-location [port-angle] | port-angle [port-location]
port-location → ’:’ id | ’:’ ’(’ id ’,’ id ’)’
port-angle → ’@’ id
edge-stmt → (node-id | subgraph) edgeRHS [attr-list]
edgeRHS → edgeop (node-id | subgraph) [edgeRHS]
subgraph → [subgraph id] ’{’ stmt-list ’}’ | subgraph id

My Program for Referential Integrity Constraints:

digraph RIC{
ranksep = 2;
{ rank = source; "starredIn"; }
{ rank = same; "starredIn"; "ticket"; "buying"; "availability"; }
{ rank = same; "emailAddress"; "address"; "creditcard"; }
{ rank = same; "star"; "employee"; }
{ rank = same; "shop"; }
{ rank = same; "customer"; "item"; "screeningHall"; }
{ rank = sink; "customer"; }
movie->screeningHall [label="hallNo->hallNo"];
starredIn->star [label="actorId->actorId"];
starredIn->movie [label="movieName->name"];
address->customer[label="customerID->id"];
emailAddress->customer[label="customerID->id"];
creditcard->customer[label="customerID->id"];
ticket->customer[label="customerID->id"];
ticket->movie[label="movieName->name"];
availability->item[label="itemId->id"];
availability->shop[label="shopId->id"];
buying->customer[label="customerID->id"];
buying->item[label="itemId->id"];
buying->shop[label="shopId->id"];
employee->screeningHall[label="hallNo->hallNo"];
employee->employee[label="superior->empId"];
}

For compiling dot -Tgif graph.dot -o graph.gif

The corresponding image is:

Referential Integrity Constraints

No comments:

Post a Comment