Graphviz 16.1.3~dev.20261205.2032
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 v2.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10
11/*
12 * Classify edges for rank assignment phase to
13 * create temporary edges.
14 */
15
16#include "config.h"
17
18#include <dotgen/dot.h>
19#include <stdbool.h>
20
22 char *constr;
23
24 if (E_constr && (constr = agxget(e, E_constr))) {
25 if (constr[0] && !mapbool(constr))
26 return true;
27 }
28 return false;
29}
30
31static void interclust1(graph_t *g, node_t *t, node_t *h, edge_t *e) {
32 node_t *v, *t0, *h0;
33 int offset, t_len, h_len, t_rank, h_rank;
34
35 if (ND_clust(agtail(e)))
36 t_rank = ND_rank(agtail(e)) - ND_rank(GD_leader(ND_clust(agtail(e))));
37 else
38 t_rank = 0;
39 if (ND_clust(aghead(e)))
40 h_rank = ND_rank(aghead(e)) - ND_rank(GD_leader(ND_clust(aghead(e))));
41 else
42 h_rank = 0;
43 offset = ED_minlen(e) + t_rank - h_rank;
44 if (offset > 0) {
45 t_len = 0;
46 h_len = offset;
47 } else {
48 t_len = -offset;
49 h_len = 0;
50 }
51
52 v = virtual_node(g);
54 t0 = UF_find(t);
55 h0 = UF_find(h);
56 edge_t *const rt = make_aux_edge(v, t0, t_len, CL_BACK * ED_weight(e));
57 edge_t *const rh = make_aux_edge(v, h0, h_len, ED_weight(e));
58 ED_to_orig(rt) = ED_to_orig(rh) = e;
59}
60void class1(graph_t *g) {
61 node_t *n, *t, *h;
62 edge_t *e, *rep;
63
65 for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
66 for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
67
68 /* skip edges already processed */
69 if (ED_to_virt(e))
70 continue;
71
72 /* skip edges that we want to ignore in this phase */
73 if (nonconstraint_edge(e))
74 continue;
75
76 t = UF_find(agtail(e));
77 h = UF_find(aghead(e));
78
79 /* skip self, flat, and intra-cluster edges */
80 if (t == h)
81 continue;
82
83 /* inter-cluster edges require special treatment */
84 if (ND_clust(t) || ND_clust(h)) {
85 interclust1(g, agtail(e), aghead(e), e);
86 continue;
87 }
88
89 if ((rep = find_fast_edge(t, h)))
90 merge_oneway(e, rep);
91 else
92 virtual_edge(t, h, e);
93 }
94 }
95}
void class1(graph_t *g)
Definition class1.c:60
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:21
bool mapbool(const char *p)
Definition utils.c:321
node_t * UF_find(node_t *n)
Definition utils.c:106
#define SLACKNODE
Definition const.h:26
#define CL_BACK
Definition const.h:141
static Dtdisc_t constr
Definition constraint.c:54
Agedge_t * virtual_edge(Agnode_t *, Agnode_t *, Agedge_t *)
Definition fastgr.c:156
void merge_oneway(Agedge_t *, Agedge_t *)
Definition fastgr.c:223
Agedge_t * make_aux_edge(Agnode_t *, Agnode_t *, double, int)
Definition position.c:179
Agedge_t * find_fast_edge(Agnode_t *, Agnode_t *)
Definition fastgr.c:43
Agnode_t * virtual_node(Agraph_t *)
Definition fastgr.c:183
Agsym_t * E_constr
Definition globals.h:85
char * agxget(void *obj, Agsym_t *sym)
Definition attr.c:457
#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:28
#define agtail(e)
Definition cgraph.h:982
#define ED_weight(e)
Definition types.h:603
#define aghead(e)
Definition cgraph.h:983
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
Definition edge.c:42
#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:50
Agnode_t * agfstnode(Agraph_t *g)
Definition node.c:43
#define ND_clust(n)
Definition types.h:489
#define ND_node_type(n)
Definition types.h:511
void mark_clusters(graph_t *g)
Definition cluster.c:288
graph or subgraph
Definition cgraph.h:424