Graphviz 13.0.0~dev.20250121.0651
|
#include <assert.h>
#include <cgraph/cghdr.h>
#include <cgraph/node_set.h>
#include <stdbool.h>
#include <stdlib.h>
#include <util/alloc.h>
#include <util/unreachable.h>
Go to the source code of this file.
Data Structures | |
struct | graphviz_node_set |
Variables | |
Dtdisc_t | Ag_subnode_seq_disc |
static Agsubnode_t *const | TOMBSTONE = (Agsubnode_t *)-1 |
a sentinel, marking a set slot from which an element has been deleted | |
Definition at line 172 of file node.c.
References agdeledgeimage(), agfstedge(), agnxtedge(), Agnode_s::base, dtdelete, Agtag_s::id, Agraph_s::n_id, Agraph_s::n_seq, Agsubnode_s::node, node_set_remove(), and Agobj_s::tag.
Referenced by agdelnode().
Definition at line 22 of file node.c.
References Agraph_s::n_id, Agsubnode_s::node, node_set_find(), and NULL.
Referenced by agdelnode(), agfindnode_by_name(), agidnode(), agnode(), agrelabel_node(), and agsubnode().
Definition at line 30 of file node.c.
References agfindnode_by_id(), agmapnametoid(), AGNODE, id, and NULL.
Referenced by agrelabel_node().
Definition at line 320 of file node.c.
References dtfinger, dtrenew(), and Agraph_s::n_seq.
Referenced by agnodebefore().
Definition at line 312 of file node.c.
References dtsearch, Agraph_s::n_seq, and Agsubnode_s::node.
Referenced by agnodebefore().
|
static |
compare a subnode to an identifier for equality
sn0 | Operand 1 |
sn1 | Operand 2 |
Definition at line 279 of file node.c.
References AGID, id, and Agsubnode_s::node.
Referenced by node_set_find(), and node_set_remove().
|
static |
Definition at line 283 of file node.c.
References AGSEQ, and Agsubnode_s::node.
Definition at line 215 of file node.c.
References AGID, agraphof(), agsubrep(), Agnode_s::base, Agtag_s::id, Agraph_s::n_id, Agsubnode_s::node, node_set_add(), node_set_remove(), NULL, and Agobj_s::tag.
Referenced by agrelabel_node().
|
static |
Definition at line 114 of file node.c.
References agmethod_init(), agnodeattr_init(), and agroot().
Referenced by agnode().
Definition at line 89 of file node.c.
References agroot(), dtinsert, dtsize(), gv_alloc(), Agnode_s::mainsub, Agraph_s::n_id, Agraph_s::n_seq, Agsubnode_s::node, node_set_add(), and node_set_size().
Referenced by agsubnode(), and installnodetoroot().
Definition at line 106 of file node.c.
References agparent(), installnode(), and installnodetoroot().
Referenced by agnode(), and installnodetoroot().
Definition at line 72 of file node.c.
References agbindrec(), AgDataRecName, AGID, AGNODE, agroot(), AGSEQ, AGTYPE, gv_alloc(), id, Agnode_s::root, and SEQ_MASK.
Referenced by agnode(), and RTreeInsert().
void node_set_add | ( | node_set_t * | self, |
Agsubnode_t * | item | ||
) |
add an item to the set
If the backing store is not large enough, it is expanded on demand. On allocation failure, exit
is called.
self | Set to add to |
item | Element to add |
Definition at line 420 of file node.c.
References graphviz_node_set::capacity_exp, free(), gv_calloc(), hash, graphviz_node_set::max, graphviz_node_set::min, graphviz_node_set::min_initialized, node_set_add(), node_set_get_capacity(), node_set_hash(), NULL, graphviz_node_set::size, graphviz_node_set::slots, TOMBSTONE, and UNREACHABLE.
Referenced by dict_relabel(), installnode(), and node_set_add().
Agsubnode_t * node_set_find | ( | node_set_t * | self, |
IDTYPE | key | ||
) |
lookup an existing item in a set
self | Set to search |
key | Identifier of node to look for |
NULL
if it was not in the set Definition at line 484 of file node.c.
References agsubnodeideq(), hash, graphviz_node_set::max, graphviz_node_set::min_initialized, node_set_get_capacity(), node_set_hash(), NULL, graphviz_node_set::slots, and TOMBSTONE.
Referenced by agfindnode_by_id(), and agsubrep().
void node_set_free | ( | node_set_t ** | self | ) |
|
static |
get the allocated size of the backing storage of a node set
The capacity of a set is represented as its base-2 exponent, to make clearer to the compiler that it can implement % capacity
as a mask, avoiding the expense of a modulo operation.
self | Set to inspect |
Definition at line 403 of file node.c.
References graphviz_node_set::capacity_exp, NULL, and graphviz_node_set::slots.
Referenced by node_set_add(), node_set_find(), and node_set_remove().
|
static |
compute a hash of a node
If the suboptimal choice of using the ID here turns out to be bad for performance, this could be converted to a more sophisticated hashing algorithm. None of the callers depend on the exact implementation.
id | Identifier of element being sought/added |
Definition at line 418 of file node.c.
References id.
Referenced by node_set_add(), node_set_find(), and node_set_remove().
node_set_t * node_set_new | ( | void | ) |
construct a new set
Calls exit
on failure (out-of-memory).
Definition at line 408 of file node.c.
References gv_alloc().
Referenced by agopen1().
void node_set_remove | ( | node_set_t * | self, |
IDTYPE | item | ||
) |
remove an item from a set
If the given item was not in the set, this is a no-op.
self | Set to remove from |
item | Identifier of element to remove |
Definition at line 519 of file node.c.
References agsubnodeideq(), hash, node_set_get_capacity(), node_set_hash(), NULL, graphviz_node_set::size, graphviz_node_set::slots, and TOMBSTONE.
Referenced by agdelnodeimage(), and dict_relabel().
size_t node_set_size | ( | const node_set_t * | self | ) |
get the number of items in a set
self | Set to query |
Definition at line 547 of file node.c.
References NULL, and graphviz_node_set::size.
Referenced by agnnodes(), installnode(), and node_set_is_empty().
Dtdisc_t Ag_subnode_seq_disc |
Definition at line 306 of file node.c.
Referenced by agopen1().
|
static |
Definition at line 393 of file node.c.
Referenced by node_set_add(), node_set_find(), and node_set_remove().