Graphviz  2.41.20170921.2350
flatten.c
Go to the documentation of this file.
1 /* $Id$ $Revision$ */
2 /* vim:set shiftwidth=4 ts=8: */
3 
4 /*************************************************************************
5  * Copyright (c) 2011 AT&T Intellectual Property
6  * All rights reserved. This program and the accompanying materials
7  * are made available under the terms of the Eclipse Public License v1.0
8  * which accompanies this distribution, and is available at
9  * http://www.eclipse.org/legal/epl-v10.html
10  *
11  * Contributors: See CVS logs. Details at http://www.graphviz.org/
12  *************************************************************************/
13 
14 #include "cghdr.h"
15 
16 static void agflatten_elist(Dict_t * d, Dtlink_t ** lptr, int flag)
17 {
18  dtrestore(d, *lptr);
19  dtmethod(d, flag? Dtlist : Dtoset);
20  *lptr = dtextract(d);
21 }
22 
23 void agflatten_edges(Agraph_t * g, Agnode_t * n, int flag)
24 {
25  Agsubnode_t *sn;
26  Dtlink_t **tmp;
27 
28  sn = agsubrep(g,n);
29  tmp = &(sn->out_seq); /* avoiding - "dereferencing type-punned pointer will break strict-aliasing rules" */
30  agflatten_elist(g->e_seq, tmp, flag);
31  tmp = &(sn->in_seq);
32  agflatten_elist(g->e_seq, tmp, flag);
33 }
34 
35 void agflatten(Agraph_t * g, int flag)
36 {
37  Agnode_t *n;
38 
39  if (flag) {
40  if (g->desc.flatlock == FALSE) {
41  dtmethod(g->n_seq,Dtlist);
42  for (n = agfstnode(g); n; n = agnxtnode(g,n))
43  agflatten_edges(g, n, flag);
44  g->desc.flatlock = TRUE;
45  }
46  } else {
47  if (g->desc.flatlock) {
48  dtmethod(g->n_seq,Dtoset);
49  for (n = agfstnode(g); n; n = agnxtnode(g,n))
50  agflatten_edges(g, n, flag);
51  g->desc.flatlock = FALSE;
52  }
53  }
54 }
55 
57 {
58  if (g->desc.flatlock)
59  agerr(AGERR, "flat lock broken");
60 }
Definition: cgraph.h:388
Agdesc_t desc
Definition: cgraph.h:241
CDT_API Dtlink_t * dtextract(Dt_t *)
unsigned flatlock
Definition: cgraph.h:155
void agflatten(Agraph_t *g, int flag)
Definition: flatten.c:35
CDT_API Dtmethod_t * Dtoset
Definition: cdt.h:166
Dict_t * n_seq
Definition: cgraph.h:243
int agerr(agerrlevel_t level, const char *fmt,...)
Definition: agerror.c:141
Dtlink_t * out_seq
Definition: cgraph.h:130
CGRAPH_API Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Definition: node.c:45
void agflatten_edges(Agraph_t *g, Agnode_t *n, int flag)
Definition: flatten.c:23
void agnotflat(Agraph_t *g)
Definition: flatten.c:56
CDT_API Dtmethod_t * dtmethod(Dt_t *, Dtmethod_t *)
Definition: dtmethod.c:8
CGRAPH_API Agnode_t * agfstnode(Agraph_t *g)
Definition: node.c:38
CGRAPH_API Agsubnode_t * agsubrep(Agraph_t *g, Agnode_t *n)
Definition: edge.c:157
CDT_API int dtrestore(Dt_t *, Dtlink_t *)
Dtlink_t * in_seq
Definition: cgraph.h:130
CDT_API Dtmethod_t * Dtlist
Definition: cdt.h:168
Definition: cdt.h:99
Dict_t * e_seq
Definition: cgraph.h:245
#define FALSE
Definition: cgraph.h:35
#define TRUE
Definition: cgraph.h:38