main() { FILE *pipe; int k1,k2,ch,n,i; NODE R=NULL; printf("\n Enter number of nodes "); scanf("%d",&n); OutputFile = fopen ("lcrs.dot", "w"); fclose (OutputFile); for(;;) { printf("\n Enter choice\n 1.Insert\n 2.Display\n 3.Exit\n "); scanf("%d",&ch); switch(ch) { case 1: for(i=0;i<n;i++) { printf("\n Enter nodes in the form n1->n2 "); scanf("%d%d",&k1,&k2); R=Insert(k1,k2,R); } break; case 2: Display(R); OutputFile=fopen("lcrs.dot","a"); if(OutputFile != NULL) { dotDump(R,OutputFile); fclose(OutputFile); } pipe=popen("dot -Tps lcrs.dot -o lcrs.ps","w"); pclose(pipe); pipe=popen("evince lcrs.ps","r"); pclose(pipe); break; default:exit(0); } } }
void maketree(int *a,int n) { int i; for(i=0; i<=n; i++) root=insert(a[i],root); output=fopen("bstpermute.dot","a"); if(output != NULL) { dotDump(root,output); } fclose(output); free(root); }
void main() { FILE *pipe; NODE H=NULL; int n,k,j; int m=0; H=Create_Leaf(0,H); H->left=H->right=H; printf("\n Enter number of nodes "); scanf("%d",&n); OutputFile = fopen ("avltree.dot", "w"); fclose (OutputFile); for(j=0;j<n;j++) { printf("Enter element"); scanf("%d",&k); //redirect from file "avlIP" H=insert(k,H); } OutputFile=fopen("avltree.dot","a"); if(OutputFile != NULL) { if(H->left!=NULL) dotDump(H->left,OutputFile); else dotDump(H->right,OutputFile); } fclose(OutputFile); pipe=popen("dot -Tps avltree.dot -o avltree.ps","w"); pclose(pipe); pipe=popen("evince avltree.ps","r"); pclose(pipe); }
int main() { Node *n=NULL; int ch; FILE *pipe; int value; Node* r = newnode(); Node** root= &r; outputFile = fopen ("234.dot", "w"); fclose (outputFile); while(1) { printf("1.Insert\n2.Display Dotty\n3.Exit\n"); scanf("%d",&ch); switch(ch) { case 1: printf("Enter the value of the node\n"); scanf("%d", &value); /*8=====>*/ n=insert(root,value); outputFile = fopen ("234.dot", "a"); if (outputFile != NULL) { dotDump (n, outputFile); } fclose (outputFile); printf("Root--\t"); display(*root,NULL); pipe=popen("dot -Tps 234.dot -o 234.ps","w"); pclose(pipe); break; case 2: pipe=popen("dot -Tps 234.dot -o 234.ps","w"); pclose(pipe); pipe=popen("evince 234.ps","r"); pclose(pipe); break; case 3: exit(0); default: printf("Enter proper choice\n"); break; } } return 0; }