34 ((AGTYPE(p) == AGRAPH) ? "graph" : (AGTYPE(p) == AGNODE) ? "node" : "edge")
36static int iofread(
void *chan,
char *buf,
int bufsize) {
39 return (
int)
read(fileno(fp), buf, bufsize);
44static int ioflush(
void *chan) {
return fflush(chan); }
73 char *
s = strstr(
s1, s2);
74 return s ==
NULL ? -1 : (int)(
s -
s1);
83 size_t len1 = strlen(
s1);
84 size_t len2 = strlen(s2);
87 assert(len1 <= LONG_MAX);
92 p =
s1 + (len1 - len2);
94 if (strncmp(p, s2, len2) == 0)
133 while ((sym =
agnxtattr(srcg, skind, sym))) {
164 if (kind !=
AGRAPH && !g) {
165 exerror(
"NULL graph with non-graph object in copy()");
242 exerror(
"edge (%s,%s)[%s] not found in cloned graph %s",
246 exerror(
"edge (%s,%s) not found in cloned graph %s",
268 else if (*key1 < *key2)
305 exerror(
"error cloning edge (%s,%s)[%s] from graph %s",
309 exerror(
"error cloning edge (%s,%s) from graph %s",
335 if (!name || *name ==
'\0')
361 if (kind !=
AGRAPH && !g) {
362 exerror(
"NULL graph with non-graph object in clone()");
401#define CCMARKED(n) (((nData(n))->iu.integer) & 2)
402#define CCMARK(n) (((nData(n))->iu.integer) |= 2)
403#define CCUNMARK(n) (((nData(n))->iu.integer) &= ~2)
435 snprintf(name,
sizeof(name),
"_cc_%d",
id++);
449 root =
sameG(t, h,
"isEdge",
"tail and head node");
458 return agedge(g, t, h, key, 0);
466 if (!
sameG(gp, np,
"addNode", 0))
476 if (!
sameG(gp, ep,
"addEdge", 0))
498 const int oldv =
data->lock.locked;
500 data->lock.locked =
true;
501 else if (v == 0 && oldv) {
502 if (
data->lock.zombie)
525 if (
data->lock.locked) {
527 data->lock.zombie =
true;
565 exerror(
"NULL string passed to writeG");
568 FILE *fp = fopen(f,
"w");
570 exwarn(
"Could not open %s for writing in writeG", f);
586 exerror(
"NULL string passed to readG");
589 FILE *fp = fopen(f,
"r");
591 exwarn(
"Could not open %s for reading in readG", f);
604 exerror(
"fwriteG: %lld: invalid descriptor", fd);
614 exerror(
"freadG: %lld: invalid descriptor", fd);
628 exerror(
"openF: no available descriptors");
641 if (0 <= fd && fd <= 2) {
642 exerror(
"closeF: cannot close standard stream %lld", fd);
646 exerror(
"closeG: %lld: invalid descriptor", fd);
650 exerror(
"closeF: stream %lld not open", fd);
653 rv = fclose(ex->
file[fd]);
669 exerror(
"readL: %lld: invalid descriptor", fd);
674 while ((c = getc(sp)) > 0 && c !=
'\n')
693 }
else if (r ==
NULL) {
708 else if (lkind < rkind)
719 const size_t len = strlen(src);
725 for (
size_t i = 0; i <
len; ++i) {
738 const size_t len = strlen(src);
744 for (
size_t i = 0; i <
len; ++i) {
782#define COLORPROCS_API static UNUSED
784#include "../common/colxlate.c"
795 if (*fmt ==
'\0' || *incolor ==
'\0')
799 if (!strcmp(fmt,
"RGBA"))
803 }
else if (*fmt ==
'H') {
805 if (!strcmp(fmt,
"HSVA"))
842#include <sys/param.h>
843#include <sys/times.h>
844#include <sys/types.h>
851#define GET_TIME(S) times(&(S))
852#define DIFF_IN_SECS(S, T) \
853 ((S.tms_utime + S.tms_stime - T.tms_utime - T.tms_stime) / (double)HZ)
860#define GET_TIME(S) S = clock()
861#define DIFF_IN_SECS(S, T) ((S - T) / (double)CLOCKS_PER_SEC)
Agedge_t * isEdge(Agraph_t *g, Agnode_t *t, Agnode_t *h, char *key)
int indexOf(char *s1, char *s2)
int openFile(Expr_t *ex, const char *fname, const char *mode)
Agraph_t * sameG(void *p1, void *p2, char *fn, char *msg)
static Agedge_t * mapEdge(Dt_t *emap, Agedge_t *e)
Agraph_t * freadFile(Expr_t *ex, long long fd)
Agobj_t * cloneO(Agraph_t *g, Agobj_t *obj)
size_t match(char *str, char *pat)
int deleteObj(Agraph_t *g, Agobj_t *obj)
int writeFile(Agraph_t *g, char *f)
int fwriteFile(Expr_t *ex, Agraph_t *g, long long fd)
long rindexOf(char *s1, char *s2)
int sfioWrite(Agraph_t *g, FILE *fp)
static void cloneGraph(Agraph_t *tgt, Agraph_t *src)
#define DIFF_IN_SECS(S, T)
static int iofread(void *chan, char *buf, int bufsize)
char * toLower(Expr_t *pgm, char *src)
Agraph_t * cloneG(Agraph_t *g, char *name)
int lockGraph(Agraph_t *g, int v)
char * canon(Expr_t *pgm, char *arg)
int copyAttr(Agobj_t *src, Agobj_t *tgt)
static void cc_dfs(Agraph_t *g, Agraph_t *comp, Agnode_t *n)
char * toHtml(Agraph_t *g, char *arg)
Agnode_t * addNode(Agraph_t *gp, Agnode_t *np, int doAdd)
int compare(Agobj_t *l, Agobj_t *r)
Agobj_t * copy(Agraph_t *g, Agobj_t *obj)
static int cmppair(void *k1, void *k2)
double gvelapsed_sec(void)
Agraph_t * readFile(char *f)
Agraph_t * compOf(Agraph_t *g, Agnode_t *n)
char * colorx(Expr_t *ex, const char *incolor, char *fmt)
static Agraph_t * cloneSubg(Agraph_t *tgt, Agraph_t *g, Dt_t *emap)
Agedge_t * addEdge(Agraph_t *gp, Agedge_t *ep, int doAdd)
static int ioflush(void *chan)
static Agiodisc_t gprIoDisc
char * toUpper(Expr_t *pgm, char *src)
static int ioputstr(void *chan, const char *str)
char * readLine(Expr_t *ex, long long fd)
int closeFile(Expr_t *ex, long long fd)
static void agxbfree(agxbuf *xb)
free any malloced resources
static int agxbprint(agxbuf *xb, const char *fmt,...)
Printf-style output to an agxbuf.
static WUR char * agxbuse(agxbuf *xb)
static int agxbputc(agxbuf *xb, char c)
add character to buffer
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
int strgrpmatch(char *, char *, size_t *, int, int)
CDT_API int dtclose(Dt_t *)
CDT_API Dtmethod_t * Dtoset
ordered set (self-adjusting tree)
CDT_API Dt_t * dtopen(Dtdisc_t *, Dtmethod_t *)
void colorxlate(char *str, agxbuf *buf)
Agedge_t * openEdge(Agraph_t *g, Agnode_t *t, Agnode_t *h, char *key)
Agraph_t * openG(char *name, Agdesc_t desc)
Agraph_t * openSubg(Agraph_t *g, char *name)
Agnode_t * openNode(Agraph_t *g, char *name)
Agraph_t * readG(FILE *fp)
void exwarn(const char *format,...)
void exerror(const char *format,...)
char * exstring(Expr_t *ex, char *s)
void * exstralloc(Expr_t *ex, size_t sz)
static double len(glCompPoint p)
int agnedges(Agraph_t *g)
Agsym_t * agattrsym(void *obj, char *name)
looks up a string attribute for a graph object given as an argument
Agsym_t * agattr(Agraph_t *g, int kind, char *name, const char *value)
creates or looks up attributes of a graph
Agsym_t * agnxtattr(Agraph_t *g, int kind, Agsym_t *attr)
permits traversing the list of attributes of a given type
int agxset(void *obj, Agsym_t *sym, const char *value)
char * agxget(void *obj, Agsym_t *sym)
Agedge_t * agedge(Agraph_t *g, Agnode_t *t, Agnode_t *h, char *name, int createflag)
Agedge_t * agsubedge(Agraph_t *g, Agedge_t *e, int createflag)
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
Agedge_t * agnxtedge(Agraph_t *g, Agedge_t *e, Agnode_t *n)
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
Agedge_t * agfstedge(Agraph_t *g, Agnode_t *n)
int agclose(Agraph_t *g)
deletes a graph, freeing its associated storage
int agwrite(Agraph_t *g, void *chan)
Return 0 on success, EOF on failure.
Agnode_t * agnode(Agraph_t *g, char *name, int createflag)
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Agnode_t * agfstnode(Agraph_t *g)
Agnode_t * agsubnode(Agraph_t *g, Agnode_t *n, int createflag)
Agnode_t * agidnode(Agraph_t *g, IDTYPE id, int createflag)
Agraph_t * agraphof(void *obj)
char * agnameof(void *)
returns a string descriptor for the object.
#define AGID(obj)
returns the unique integer ID associated with the object
#define AGTYPE(obj)
returns AGRAPH, AGNODE, or AGEDGE depending on the type of the object
int agdelete(Agraph_t *g, void *obj)
deletes object. Equivalent to agclose, agdelnode, and agdeledge for obj being a graph,...
Agraph_t * agroot(void *obj)
int aghtmlstr(const char *)
int agstrfree(Agraph_t *, const char *)
char * agcanonStr(char *str)
char * agstrdup_html(Agraph_t *, const char *)
Agraph_t * agfstsubg(Agraph_t *g)
Agraph_t * agnxtsubg(Agraph_t *subg)
replacements for ctype.h functions
static char gv_toupper(int c)
static char gv_tolower(int c)
static void color(Agraph_t *g)
textitem scanner parser str
NEATOPROCS_API void s1(graph_t *, node_t *)
static double cg(SparseMatrix A, const double *precond, int n, int dim, double *x0, double *rhs, double tol, double maxit)
platform abstraction for case-insensitive string functions
a generic header of Agraph_s, Agnode_s and Agedge_s
Agclos_t * clos
shared resources
abstraction for squashing compiler warnings for unused symbols