~ubuntu-branches/ubuntu/lucid/graphviz/lucid-updates

« back to all changes in this revision

Viewing changes to cmd/gvpr/actions.c

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2008-06-19 20:23:23 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080619202323-ls23h96ntj9ny94m
Tags: 2.18-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Build depend on liblualib50-dev instead of liblua5.1-0-dev.
  - Drop libttf-dev (libttf-dev is in universe) (LP: #174749).
  - Replace gs-common with ghostscript.
  - Build-depend on python-dev instead of python2.4-dev or python2.5-dev.
  - Mention the correct python version for the python bindings in the
    package description.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: actions.c,v 1.2 2005/03/16 22:03:27 erg Exp $ $Revision: 1.2 $ */
 
1
/* $Id: actions.c,v 1.3 2008/01/09 22:36:19 erg Exp $ $Revision: 1.3 $ */
2
2
/* vim:set shiftwidth=4 ts=8: */
3
3
 
4
4
/**********************************************************
104
104
    base = agroot(selected);
105
105
    if (base == selected)
106
106
        return;
 
107
#ifdef USE_CGRAPH
 
108
    for (n = agfstnode(selected); n; n = agnxtnode(selected, n)) {
 
109
        for (e = agfstout(selected, n); e; e = agnxtout(selected, e)) {
 
110
#else
107
111
    for (n = agfstnode(selected); n; n = agnxtnode(n)) {
108
112
        for (e = agfstout(agsubnode(base, n, FALSE)); e; e = agnxtout(e)) {
 
113
#endif
109
114
            if (agsubnode(selected, aghead(e), FALSE))
110
115
                agsubedge(selected, e, TRUE);
111
116
        }
175
180
        e = (Agedge_t *) obj;
176
181
        t = openNode(g, agnameof(agtail(e)));
177
182
        h = openNode(g, agnameof(aghead(e)));
178
 
        nobj = (Agobj_t *) openEdge(t, h, name);
 
183
        nobj = (Agobj_t *) openEdge(g, t, h, name);
179
184
        break;
180
185
    }
181
186
    if (nobj)
200
205
    ng = (Agraph_t *) (copy(tgt, OBJ(g)));
201
206
    if (!ng)
202
207
        return 0;
 
208
#ifdef USE_CGRAPH
 
209
    for (t = agfstnode(g); t; t = agnxtnode(g, t)) {
 
210
#else
203
211
    for (t = agfstnode(g); t; t = agnxtnode(t)) {
 
212
#endif
204
213
        newt = agnode(tgt, agnameof(t), 0);
205
214
        if (!newt)
206
215
            error(ERROR_PANIC, "node %s not found in cloned graph %s",
207
216
                  agnameof(t), agnameof(tgt));
208
217
        agsubnode(ng, newt, 1);
209
218
    }
 
219
#ifdef USE_CGRAPH
 
220
    for (t = agfstnode(g); t; t = agnxtnode(g, t)) {
 
221
#else
210
222
    for (t = agfstnode(g); t; t = agnxtnode(t)) {
 
223
#endif
211
224
        newt = agnode(tgt, agnameof(t), 0);
 
225
#ifdef USE_CGRAPH
 
226
        for (e = agfstout(g, t); e; e = agnxtout(g, e)) {
 
227
#else
212
228
        for (e = agfstout(t); e; e = agnxtout(e)) {
 
229
#endif
213
230
            newh = agnode(tgt, agnameof(aghead(e)), 0);
 
231
#ifdef USE_CGRAPH
 
232
            newe = agedge(tgt, newt, newh, agnameof(e), 0);
 
233
#else
214
234
            newe = agedge(newt, newh, agnameof(e), 0);
 
235
#endif
215
236
            if (!newe)
216
237
                error(ERROR_PANIC,
217
238
                      "edge (%s,%s)[%s] not found in cloned graph %s",
238
259
    Agnode_t *t;
239
260
    Agraph_t *sg;
240
261
 
 
262
#ifdef USE_CGRAPH
 
263
    for (t = agfstnode(src); t; t = agnxtnode(src, t)) {
 
264
#else
241
265
    for (t = agfstnode(src); t; t = agnxtnode(t)) {
 
266
#endif
242
267
        if (!copy(tgt, OBJ(t))) {
243
268
            error(ERROR_FATAL, "error cloning node %s from graph %s",
244
269
                  agnameof(t), agnameof(src));
245
270
        }
246
271
    }
 
272
#ifdef USE_CGRAPH
 
273
    for (t = agfstnode(src); t; t = agnxtnode(src, t)) {
 
274
        for (e = agfstout(src, t); e; e = agnxtout(src, e)) {
 
275
#else
247
276
    for (t = agfstnode(src); t; t = agnxtnode(t)) {
248
277
        for (e = agfstout(t); e; e = agnxtout(e)) {
 
278
#endif
249
279
            if (!copy(tgt, OBJ(e))) {
250
280
                error(ERROR_FATAL,
251
281
                      "error cloning edge (%s,%s)[%s] from graph %s",
303
333
        e = (Agedge_t *) obj;
304
334
        t = (Agnode_t *) clone(g, OBJ(agtail(e)));
305
335
        h = (Agnode_t *) clone(g, OBJ(aghead(e)));
306
 
        nobj = (Agobj_t *) openEdge(t, h, name);
 
336
        nobj = (Agobj_t *) openEdge(g, t, h, name);
307
337
        if (nobj)
308
338
            copyAttr(obj, nobj);
309
339
        break;
316
346
#define CCMARK(n)    (((nData(n))->iu.integer) |= 2)
317
347
#define CCUNMARK(n)  (((nData(n))->iu.integer) &= ~2)
318
348
 
319
 
static void cc_dfs(Agraph_t * comp, Agnode_t * n)
 
349
static void cc_dfs(Agraph_t* g, Agraph_t * comp, Agnode_t * n)
320
350
{
321
351
    Agedge_t *e;
322
352
    Agnode_t *other;
323
353
 
324
354
    CCMARK(n);
325
355
    agidnode(comp, AGID(n), 1);
 
356
#ifdef USE_CGRAPH
 
357
    for (e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) {
 
358
#else
326
359
    for (e = agfstedge(n); e; e = agnxtedge(e, n)) {
 
360
#endif
327
361
        if (agtail(e) == n)
328
362
            other = aghead(e);
329
363
        else
330
364
            other = agtail(e);
331
365
        if (!CCMARKED(other))
332
 
            cc_dfs(comp, other);
 
366
            cc_dfs(g, comp, other);
333
367
    }
334
368
}
335
369
 
345
379
 
346
380
    if (!(n = agidnode(g, AGID(n), 0)))
347
381
        return 0;               /* n not in g */
 
382
#ifdef USE_CGRAPH
 
383
    for (np = agfstnode(g); np; np = agnxtnode(g, np))
 
384
#else
348
385
    for (np = agfstnode(g); np; np = agnxtnode(np))
 
386
#endif
349
387
        CCUNMARK(np);
350
388
 
351
389
    sprintf(name, "_cc_%d", id++);
352
390
    cg = openSubg(g, name);
353
 
    cc_dfs(cg, n);
 
391
    cc_dfs(g, cg, n);
354
392
 
355
393
    return cg;
356
394
}
359
397
 * Return edge, if any, between t and h with given key.
360
398
 * Edge is in root graph
361
399
 */
362
 
Agedge_t *isEdge(Agnode_t * t, Agnode_t * h, char *key)
 
400
Agedge_t *isEdge(Agraph_t* g, Agnode_t * t, Agnode_t * h, char *key)
363
401
{
364
402
    Agraph_t *root;
365
403
 
 
404
#ifdef USE_CGRAPH
 
405
    root = sameG(t, h, "isEdge", "tail and head node");
 
406
    if (!root)
 
407
        return 0;
 
408
    if (g && (root != agroot(g)))
 
409
        return 0;
 
410
    else
 
411
        g = root;
 
412
 
 
413
    return agedge(g, t, h, key, 0);
 
414
#else
366
415
    if ((root = sameG(t, h, "isEdge", "tail and head node"))) {
367
416
        t = (Agnode_t *) agrebind(root, OBJ(t));
368
417
        h = (Agnode_t *) agrebind(root, OBJ(h));
369
418
        return agedge(t, h, key, 0);
370
419
    } else
371
420
        return 0;
 
421
#endif
372
422
}
373
423
 
374
424
/* isIn:
392
442
 * Insert node n into subgraph g.
393
443
 * Return image of n
394
444
 */
395
 
Agnode_t *addNode(Agraph_t * gp, Agnode_t * np)
 
445
Agnode_t *addNode(Agraph_t * gp, Agnode_t * np, int doAdd)
396
446
{
397
447
    if (!sameG(gp, np, "addNode", 0))
398
448
        return 0;
399
 
    return agsubnode(gp, np, 1);
 
449
    return agsubnode(gp, np, doAdd);
400
450
}
401
451
 
402
452
/* addEdge:
403
453
 * Insert edge e into subgraph g.
404
454
 * Return image of e
405
455
 */
406
 
Agedge_t *addEdge(Agraph_t * gp, Agedge_t * ep)
 
456
Agedge_t *addEdge(Agraph_t * gp, Agedge_t * ep, int doAdd)
407
457
{
408
458
    if (!sameG(gp, ep, "addEdge", 0))
409
459
        return 0;
410
 
    return agsubedge(gp, ep, 1);
 
460
    return agsubedge(gp, ep, doAdd);
411
461
}
412
462
 
413
463
/* lockGraph:
470
520
    /* node or edge */
471
521
    if (!g)
472
522
        g = agroot(agraphof(obj));
 
523
#ifndef USE_CGRAPH
473
524
    obj = agrebind(g, obj);
 
525
#endif
474
526
    if (obj)
475
527
        return agdelete(g, obj);
476
528
    else