16 int nodecmd(ClientData clientData, Tcl_Interp * interp,
18 int argc,
char *argv[]
20 int argc, Tcl_Obj * CONST objv[]
25 int i, j, length, argc2;
33 Tcl_AppendResult(interp,
"Wrong # args: should be \"", argv[0],
" option ?arg arg ...?\"",
NULL);
38 Tcl_AppendResult(interp,
"Node \"", argv[0],
"\" not found",
NULL);
44 length = strlen(argv[1]);
47 if ((c ==
'a') && (strncmp(argv[1],
"addedge", length) == 0)) {
48 if ((argc < 3) || (!(argc % 2))) {
49 Tcl_AppendResult(interp,
"Wrong # args: should be \"", argv[0],
" addedge head ?attributename attributevalue? ?...?\"",
NULL);
52 head =
cmd2n(argv[2]);
55 Tcl_AppendResult(interp,
"Head node \"", argv[2],
"\" not found.",
NULL);
60 Tcl_AppendResult(interp,
"Nodes ", argv[0],
" and ", argv[2],
" are not in the same graph.",
NULL);
68 }
else if ((c ==
'd') && (strncmp(argv[1],
"delete", length) == 0)) {
72 }
else if ((c ==
'f') && (strncmp(argv[1],
"findedge", length) == 0)) {
74 Tcl_AppendResult(interp,
"Wrong # args: should be \"", argv[0],
" findedge headnodename\"",
NULL);
78 Tcl_AppendResult(interp,
"Head node \"", argv[2],
"\" not found.",
NULL);
82 Tcl_AppendResult(interp,
"Edge \"", argv[0],
" - ",
obj2cmd(head),
"\" not found.",
NULL);
85 Tcl_AppendElement(interp,
obj2cmd(head));
89 && (strncmp(argv[1],
"listattributes", length) == 0)) {
93 }
else if ((c ==
'l') && (strncmp(argv[1],
"listedges", length) == 0)) {
95 Tcl_AppendElement(interp,
obj2cmd(e));
100 && (strncmp(argv[1],
"listinedges", length) == 0)) {
102 Tcl_AppendElement(interp,
obj2cmd(e));
106 }
else if ((c ==
'l')
107 && (strncmp(argv[1],
"listoutedges", length) == 0)) {
109 Tcl_AppendElement(interp,
obj2cmd(e));
113 }
else if ((c ==
'q')
114 && (strncmp(argv[1],
"queryattributes", length) == 0)) {
115 for (i = 2; i < argc; i++) {
117 (interp, argv[i], &argc2,
118 (
CONST84 char ***) &argv2) != TCL_OK)
120 for (j = 0; j < argc2; j++) {
122 Tcl_AppendElement(interp,
agxget(n, a));
124 Tcl_AppendResult(interp,
"No attribute named \"", argv2[j],
"\"",
NULL);
128 Tcl_Free((
char *) argv2);
132 }
else if ((c ==
'q')
133 && (strncmp(argv[1],
"queryattributevalues", length) ==
135 for (i = 2; i < argc; i++) {
137 (interp, argv[i], &argc2,
138 (
CONST84 char ***) &argv2) != TCL_OK)
140 for (j = 0; j < argc2; j++) {
142 Tcl_AppendElement(interp, argv2[j]);
143 Tcl_AppendElement(interp,
agxget(n, a));
145 Tcl_AppendResult(interp,
"No attribute named \"", argv2[j],
"\"",
NULL);
149 Tcl_Free((
char *) argv2);
153 }
else if ((c ==
's')
154 && (strncmp(argv[1],
"setattributes", length) == 0)) {
158 (interp, argv[2], &argc2,
159 (
CONST84 char ***) &argv2) != TCL_OK)
161 if ((argc2 == 0) || (argc2 % 2)) {
162 Tcl_AppendResult(interp,
"Wrong # args: should be \"", argv[0],
163 "\" setattributes attributename attributevalue ?attributename attributevalue? ?...?",
165 Tcl_Free((
char *) argv2);
169 Tcl_Free((
char *) argv2);
171 if ((argc < 4) || (argc % 2)) {
172 Tcl_AppendResult(interp,
"Wrong # args: should be \"", argv[0],
173 "\" setattributes attributename attributevalue ?attributename attributevalue? ?...?",
181 }
else if ((c ==
's') && (strncmp(argv[1],
"showname", length) == 0)) {
182 Tcl_SetResult(interp,
agnameof(n), TCL_STATIC);
186 Tcl_AppendResult(interp,
"Bad option \"", argv[1],
187 "\": must be one of:",
188 "\n\taddedge, listattributes, listedges, listinedges,",
189 "\n\tlistoutedges, queryattributes, queryattributevalues,",
190 "\n\tsetattributes, showname.",
NULL);
void listNodeAttrs(Tcl_Interp *interp, Agraph_t *g)
Agnode_t * cmd2n(char *cmd)
CGRAPH_API Agedge_t * agfstin(Agraph_t *g, Agnode_t *n)
char * obj2cmd(void *obj)
CGRAPH_API Agedge_t * agfstedge(Agraph_t *g, Agnode_t *n)
CGRAPH_API Agraph_t * agroot(void *obj)
CGRAPH_API Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
CGRAPH_API Agraph_t * agraphof(void *obj)
CGRAPH_API char * agnameof(void *)
int nodecmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
CGRAPH_API Agedge_t * agnxtedge(Agraph_t *g, Agedge_t *e, Agnode_t *n)
void setedgeattributes(Agraph_t *g, Agedge_t *e, char *argv[], int argc)
void deleteNode(gctx_t *gctx, Agraph_t *g, Agnode_t *n)
CGRAPH_API Agedge_t * agedge(Agraph_t *g, Agnode_t *t, Agnode_t *h, char *name, int createflag)
CGRAPH_API Agedge_t * agnxtin(Agraph_t *g, Agedge_t *e)
void setnodeattributes(Agraph_t *g, Agnode_t *n, char *argv[], int argc)
#define agfindedge(g, t, h)
char * agxget(void *obj, Agsym_t *sym)
CGRAPH_API Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
#define agfindnodeattr(g, a)