Graphviz 14.1.3~dev.20260124.0732
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 "config.h"
18
19#include <dotgen/dot.h>
20#include <stdbool.h>
21
23 char *constr;
24
25 if (E_constr && (constr = agxget(e, E_constr))) {
26 if (constr[0] && !mapbool(constr))
27 return true;
28 }
29 return false;
30}
31
32static void
34{
35 node_t *v, *t0, *h0;
36 int offset, t_len, h_len, t_rank, h_rank;
37
38 if (ND_clust(agtail(e)))
39 t_rank = ND_rank(agtail(e)) - ND_rank(GD_leader(ND_clust(agtail(e))));
40 else
41 t_rank = 0;
42 if (ND_clust(aghead(e)))
43 h_rank = ND_rank(aghead(e)) - ND_rank(GD_leader(ND_clust(aghead(e))));
44 else
45 h_rank = 0;
46 offset = ED_minlen(e) + t_rank - h_rank;
47 if (offset > 0) {
48 t_len = 0;
49 h_len = offset;
50 } else {
51 t_len = -offset;
52 h_len = 0;
53 }
54
55 v = virtual_node(g);
57 t0 = UF_find(t);
58 h0 = UF_find(h);
59 edge_t *const rt = make_aux_edge(v, t0, t_len, CL_BACK * ED_weight(e));
60 edge_t *const rh = make_aux_edge(v, h0, h_len, ED_weight(e));
61 ED_to_orig(rt) = ED_to_orig(rh) = e;
62}
63void class1(graph_t * g)
64{
65 node_t *n, *t, *h;
66 edge_t *e, *rep;
67
69 for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
70 for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
71
72 /* skip edges already processed */
73 if (ED_to_virt(e))
74 continue;
75
76 /* skip edges that we want to ignore in this phase */
77 if (nonconstraint_edge(e))
78 continue;
79
80 t = UF_find(agtail(e));
81 h = UF_find(aghead(e));
82
83 /* skip self, flat, and intra-cluster edges */
84 if (t == h)
85 continue;
86
87
88 /* inter-cluster edges require special treatment */
89 if (ND_clust(t) || ND_clust(h)) {
90 interclust1(g, agtail(e), aghead(e), e);
91 continue;
92 }
93
94 if ((rep = find_fast_edge(t, h)))
95 merge_oneway(e, rep);
96 else
97 virtual_edge(t, h, e);
98 }
99 }
100}
101
void class1(graph_t *g)
Definition class1.c:63
static void interclust1(graph_t *g, node_t *t, node_t *h, edge_t *e)
Definition class1.c:33
bool nonconstraint_edge(edge_t *e)
Definition class1.c:22
bool mapbool(const char *p)
Definition utils.c:341
node_t * UF_find(node_t *n)
Definition utils.c:104
#define SLACKNODE
Definition const.h:26
#define CL_BACK
Definition const.h:141
static Dtdisc_t constr
Definition constraint.c:52
Agedge_t * virtual_edge(Agnode_t *, Agnode_t *, Agedge_t *)
Definition fastgr.c:170
void merge_oneway(Agedge_t *, Agedge_t *)
Definition fastgr.c:289
Agedge_t * make_aux_edge(Agnode_t *, Agnode_t *, double, int)
Definition position.c:178
Agedge_t * find_fast_edge(Agnode_t *, Agnode_t *)
Definition fastgr.c:43
Agnode_t * virtual_node(Agraph_t *)
Definition fastgr.c:200
Agsym_t * E_constr
Definition globals.h:85
char * agxget(void *obj, Agsym_t *sym)
Definition attr.c:460
#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:977
#define ED_weight(e)
Definition types.h:603
#define aghead(e)
Definition cgraph.h:978
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
Definition edge.c:43
#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:299
graph or subgraph
Definition cgraph.h:424