Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
class1.c
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (c) 2011 AT&T Intellectual Property
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10
11
12/*
13 * Classify edges for rank assignment phase to
14 * create temporary edges.
15 */
16
17#include <dotgen/dot.h>
18#include <stdbool.h>
19
21 char *constr;
22
23 if (E_constr && (constr = agxget(e, E_constr))) {
24 if (constr[0] && !mapbool(constr))
25 return true;
26 }
27 return false;
28}
29
30static void
32{
33 node_t *v, *t0, *h0;
34 int offset, t_len, h_len, t_rank, h_rank;
35 edge_t *rt, *rh;
36
37 if (ND_clust(agtail(e)))
38 t_rank = ND_rank(agtail(e)) - ND_rank(GD_leader(ND_clust(agtail(e))));
39 else
40 t_rank = 0;
41 if (ND_clust(aghead(e)))
42 h_rank = ND_rank(aghead(e)) - ND_rank(GD_leader(ND_clust(aghead(e))));
43 else
44 h_rank = 0;
45 offset = ED_minlen(e) + t_rank - h_rank;
46 if (offset > 0) {
47 t_len = 0;
48 h_len = offset;
49 } else {
50 t_len = -offset;
51 h_len = 0;
52 }
53
54 v = virtual_node(g);
56 t0 = UF_find(t);
57 h0 = UF_find(h);
58 rt = make_aux_edge(v, t0, t_len, CL_BACK * ED_weight(e));
59 rh = make_aux_edge(v, h0, h_len, ED_weight(e));
60 ED_to_orig(rt) = ED_to_orig(rh) = e;
61}
62void class1(graph_t * g)
63{
64 node_t *n, *t, *h;
65 edge_t *e, *rep;
66
68 for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
69 for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
70
71 /* skip edges already processed */
72 if (ED_to_virt(e))
73 continue;
74
75 /* skip edges that we want to ignore in this phase */
76 if (nonconstraint_edge(e))
77 continue;
78
79 t = UF_find(agtail(e));
80 h = UF_find(aghead(e));
81
82 /* skip self, flat, and intra-cluster edges */
83 if (t == h)
84 continue;
85
86
87 /* inter-cluster edges require special treatment */
88 if (ND_clust(t) || ND_clust(h)) {
89 interclust1(g, agtail(e), aghead(e), e);
90 continue;
91 }
92
93 if ((rep = find_fast_edge(t, h)))
94 merge_oneway(e, rep);
95 else
96 virtual_edge(t, h, e);
97 }
98 }
99}
100
void class1(graph_t *g)
Definition class1.c:62
static void interclust1(graph_t *g, node_t *t, node_t *h, edge_t *e)
Definition class1.c:31
bool nonconstraint_edge(edge_t *e)
Definition class1.c:20
bool mapbool(const char *p)
Definition utils.c:335
node_t * UF_find(node_t *n)
Definition utils.c:98
#define SLACKNODE
Definition const.h:26
#define CL_BACK
Definition const.h:150
static Dtdisc_t constr
Definition constraint.c:51
Agedge_t * virtual_edge(Agnode_t *, Agnode_t *, Agedge_t *)
Definition fastgr.c:172
void merge_oneway(Agedge_t *, Agedge_t *)
Definition fastgr.c:291
Agedge_t * make_aux_edge(Agnode_t *, Agnode_t *, double, int)
Definition position.c:176
Agedge_t * find_fast_edge(Agnode_t *, Agnode_t *)
Definition fastgr.c:41
Agnode_t * virtual_node(Agraph_t *)
Definition fastgr.c:202
Agsym_t * E_constr
Definition globals.h:84
char * agxget(void *obj, Agsym_t *sym)
Definition attr.c:455
#define ED_to_orig(e)
Definition types.h:598
#define ED_minlen(e)
Definition types.h:592
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
Definition edge.c:24
#define agtail(e)
Definition cgraph.h:880
#define ED_weight(e)
Definition types.h:603
#define aghead(e)
Definition cgraph.h:881
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
Definition edge.c:39
#define ED_to_virt(e)
Definition types.h:599
#define GD_leader(g)
Definition types.h:375
#define ND_rank(n)
Definition types.h:523
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Definition node.c:47
Agnode_t * agfstnode(Agraph_t *g)
Definition node.c:40
#define ND_clust(n)
Definition types.h:489
#define ND_node_type(n)
Definition types.h:511
swig_ptr_object_handlers offset
Definition gv_php.cpp:5907
void mark_clusters(graph_t *g)
Definition cluster.c:308
graph or subgraph
Definition cgraph.h:425