~ubuntu-branches/ubuntu/lucid/graphviz/lucid-security

« back to all changes in this revision

Viewing changes to tools/gpr/actions.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen M Moraco
  • Date: 2002-02-05 18:52:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020205185212-8i04c70te00rc40y
Tags: upstream-1.7.16
ImportĀ upstreamĀ versionĀ 1.7.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <actions.h>
 
2
#include <error.h>
 
3
 
 
4
void 
 
5
nodeInduce(Agraph_t *selected)
 
6
{
 
7
  Agnode_t*   n;
 
8
  Agedge_t*   e;
 
9
  Agraph_t*   base;
 
10
 
 
11
  if (!selected) return;
 
12
  base = agroot (selected);
 
13
  if (base == selected) return;
 
14
  for (n = agfstnode(selected); n; n = agnxtnode(n)) {
 
15
    for (e = agfstout(agsubnode(base,n,FALSE)); e; e = agnxtout(e)) {
 
16
      if (agsubnode(selected,aghead(e),FALSE))
 
17
        agsubedge(selected,e,TRUE);
 
18
    }
 
19
  }
 
20
}
 
21
 
 
22
/* copyAttr;
 
23
 * Copy attributes from src to tgt. Overrides currently
 
24
 * defined values.
 
25
 */
 
26
static void
 
27
copyAttr (int kind, Agobj_t* src, Agobj_t* tgt)
 
28
{
 
29
  Agraph_t*  srcg;
 
30
  Agraph_t*  tgtg;
 
31
  Agsym_t*   sym = 0;
 
32
  Agsym_t*   tsym = 0;
 
33
 
 
34
  srcg = agraphof(src);
 
35
  tgtg = agraphof(tgt);
 
36
  while (sym = agnxtattr(srcg,kind,sym)) {
 
37
    tsym = agattrsym (tgt, sym->name);
 
38
    if (!tsym)
 
39
      tsym = agattr(tgtg,kind,sym->name,"");
 
40
    agxset (tgt, tsym, agxget(src,sym));
 
41
  }
 
42
}
 
43
 
 
44
/* clone:
 
45
 * Create new object of type AGTYPE(obj) with all of its
 
46
 * attributes.
 
47
 * If obj is an edge, create end nodes if necessary, but
 
48
 * do not copy the attributes.
 
49
 * If obj is a graph, if g is null, create a clone top-level
 
50
 * graph. Otherwise, create a clone subgraph of g.
 
51
 */
 
52
Agobj_t* clone(Agraph_t *g, Agobj_t* obj)
 
53
{
 
54
  Agobj_t*   nobj = 0;
 
55
  Agedge_t*  e;
 
56
  Agnode_t*  h;
 
57
  Agnode_t*  t;
 
58
  int        kind = AGTYPE(obj);
 
59
 
 
60
  if (!obj || ((kind != AGRAPH) && !g)) return 0;
 
61
 
 
62
  switch (kind) {
 
63
  case AGNODE :
 
64
    nobj = (Agobj_t*)agnode (g, agnameof(obj), 1);
 
65
    if (nobj) copyAttr (kind,obj,nobj);
 
66
    break;
 
67
  case AGRAPH :
 
68
    error (3, "clone of graph unimplemented");
 
69
    break;
 
70
  case AGEDGE :
 
71
    e = (Agedge_t*)obj;
 
72
    t = agnode (g, agnameof(agtail(e)), 1);
 
73
    h = agnode (g, agnameof(aghead(e)), 1);
 
74
    nobj = (Agobj_t*)agedge (t, h, agnameof(obj), 1);
 
75
    if (nobj) copyAttr (kind,obj,nobj);
 
76
    break;
 
77
  }
 
78
 
 
79
  return nobj;
 
80
}
 
81