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