Graphviz 12.0.1~dev.20240715.2254
Loading...
Searching...
No Matches
node_induce.c
Go to the documentation of this file.
1
5#include <assert.h>
6#include <cgraph/cghdr.h>
7#include <stddef.h>
8
10
11 assert(g != NULL);
12
13 if (edgeset == NULL) {
14 edgeset = agroot(g);
15 }
16
17 // if the graph and the edge set are the same, by implication the graph
18 // already contains all the edges we would consider adding
19 if (g == edgeset) {
20 return 0;
21 }
22
23 size_t count = 0;
24 for (Agnode_t *n = agfstnode(g); n != NULL; n = agnxtnode(g, n)) {
25 for (Agedge_t *e = agfstout(edgeset, n); e != NULL;
26 e = agnxtout(edgeset, e)) {
27 if (agsubnode(g, aghead(e), 0)) {
28 agsubedge(g, e, 1);
29 ++count;
30 }
31 }
32 }
33
34 return count;
35}
cgraph.h additions
node NULL
Definition grammar.y:149
size_t graphviz_node_induce(Agraph_t *g, Agraph_t *edgeset)
Definition node_induce.c:9
Agedge_t * agsubedge(Agraph_t *g, Agedge_t *e, int createflag)
Definition edge.c:355
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
Definition edge.c:23
#define aghead(e)
Definition cgraph.h:890
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
Definition edge.c:38
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Definition node.c:47
Agnode_t * agfstnode(Agraph_t *g)
Definition node.c:40
Agnode_t * agsubnode(Agraph_t *g, Agnode_t *n, int createflag)
Definition node.c:261
Agraph_t * agroot(void *obj)
Definition obj.c:167
graph or subgraph
Definition cgraph.h:425