INGOR
Loading...
Searching...
No Matches
ytGraph.h
1/*
2 math/ytGraph.{h,c} : Graph
3 Copyright (C) 2018, Yoshinori Tamada <tamada A T ytlab.jp>
4 All rights reserved.
5
6 See LICENSE.txt for details of the licensing agreement.
7*/
8
9#ifndef __YTLIB_GRAPH_H
10#define __YTLIB_GRAPH_H
11
12#include "lang/ytObject.h"
13#include <stdio.h>
14#ifdef USE_MPI
15#include <mpi.h>
16#endif
17
24typedef struct ytGraph_t ytGraph;
25
26typedef struct {
27 int src;
28 int dst;
29 int k;
31
32typedef struct ytGraph_t {
33 ytObject obj;
34
35 void (* setOrder)(ytGraph * g, int order);
36 void (* delete)(ytGraph * g);
37 ytGraph * (*clone)(const ytGraph * g);
38 int (* numNodes)(const ytGraph * g);
39 int (* numEdges)(const ytGraph * g);
40 int (* checkEdge)(const ytGraph * g, int u, int v);
41 int (* degree)(const ytGraph * g, int u);
42 int (* numParents)(const ytGraph * g, int u);
43 int (* numChildren)(const ytGraph * g, int u);
44 void (* addEdge)(ytGraph * g, int u, int v);
45
46 const int * (* getParents)(const ytGraph * g, int u);
47 const int * (* getChildren)(const ytGraph *g, int u);
48 void (* removeEdge)(ytGraph * g, int u, int v);
49 void (* clear)(ytGraph * g);
50
51 void (* print)(const ytGraph * g, FILE * fp);
52
53 ytGraphEdgeIter * (*edgeIter)(const ytGraph * g);
54 void (*edgeIterNext)(const ytGraph * g, ytGraphEdgeIter * iter);
55
56#ifdef USE_MPI
57 void (* MPI_Bcast)(ytObject ** pg, int root, MPI_Comm comm);
58#endif
59} ytGraph;
60
61#define ytGraph_setOrder(g,n) g->setOrder(g,n)
62#define ytGraph_delete(g) g->delete(g)
63#define ytGraph_clone(g) g->clone(g)
64#define ytGraph_degree(g,u) g->degree(g,u)
65#define ytGraph_addEdge(g,u,v) g->addEdge(g,u,v)
66#define ytGraph_clear(g) g->clear(g)
67#ifdef DOXY
71
75
79int ytGraph_checkEdge(const ytGraph * g, int u, int v);
80
93const int * ytGraph_getParents(const ytGraph * g, int u);
94
97int ytGraph_numParents(const ytGraph * g, int u);
98
110const int * ytGraph_getChildren(const ytGraph * g, int u);
111
116int ytGraph_numChildren(const ytGraph * g, int u);
117
120void ytGraph_removeEdge(ytGraph * g, int u, int v);
121
124void ytGraph_print(const ytGraph * g, FILE * fp);
125
129
133
136void ytGraph_MPI_Bcast(ytObject ** pg, int root, MPI_Comm comm);
137
138#else
139#define ytGraph_numNodes(g) g->numNodes(g)
140#define ytGraph_numEdges(g) g->numEdges(g)
141#define ytGraph_checkEdge(g,u,v) g->checkEdge(g,u,v)
142#define ytGraph_getParents(g,u) g->getParents(g,u)
143#define ytGraph_numParents(g,u) g->numParents(g,u)
144#define ytGraph_getChildren(g,u) g->getChildren(g,u)
145#define ytGraph_numChildren(g,u) g->numChildren(g,u)
146#define ytGraph_removeEdge(g,u,v) g->removeEdge(g,u,v)
147#define ytGraph_print(g,fp) g->print(g,fp)
148#define ytGraph_edgeIter(g) g->edgeIter(g)
149#define ytGraph_edgeIterNext(g,i) g->edgeIterNext(g,i)
150#ifdef USE_MPI
151#define ytGraph_MPI_Bcast(pg,r,c) (*pg)->MPI_Bcast(pg,r,c)
152#endif
153#endif /* DOXY */
154
155size_t ytGraph_size(const ytGraph * this);
156ytByte * ytGraph_serialize(const ytGraph * this, ytByte ** pptr);
157ytByte * ytGraph_serializeI(const ytObject * obj, ytByte ** pptr);
158ytGraph * ytGraph_deserialize(ytByte ** const pptr);
159
160#endif /* __YTLIB_GRAPH_H */
Interface class for handling graph structure.
int ytGraph_checkEdge(const ytGraph *g, int u, int v)
Checks if the specified edge exists.
int ytGraph_numNodes(const ytGraph *g)
Returns the number of nodes in the graph.
void ytGraph_edgeIterNext(const ytGraph *g, ytGraphEdgeIter *i)
Obtains the next edge.
void ytGraph_removeEdge(ytGraph *g, int u, int v)
Removes the specified edge.
int ytGraph_numChildren(const ytGraph *g, int u)
Returns the number of children.
int ytGraph_numParents(const ytGraph *g, int u)
Return the number of parents for the specified node.
const int * ytGraph_getChildren(const ytGraph *g, int u)
Returns the integer array that contains the indices of children.
int ytGraph_numEdges(const ytGraph *g)
Returns the number of edges in the graph.
ytGraphEdgeIter * ytGraph_edgeIter(const ytGrpah *g)
Returns the ytGraphEdgeIter instance representing the first edge.
void ytGraph_MPI_Bcast(ytObject **pg, int root, MPI_Comm comm)
[MPI] Broadcasts the graph to all the processes.
const int * ytGraph_getParents(const ytGraph *g, int u)
Returns the integer array that contains the indices of parents of the specifiec node.
The basis class.
Definition ytGraph.h:32
Definition ytGraph.h:26