INGOR
ytPCGraph.h
1/*
2 math/ytPCGraph.{h,c} : Parent & Child list Graph
3 Copyright (C) 2018, Yoshinori Tamada <tamada A T ytlab.jp>
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9
10 * Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12
13 * Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in
15 the documentation and/or other materials provided with the
16 distribution.
17
18 * Neither the name of Kyoto University nor the names of its
19 contributors may be used to endorse or promote products derived
20 from this software without specific prior written permission.
21
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 POSSIBILITY OF SUCH DAMAGE.
34*/
35
36#ifndef __YTLIB_PC_GRAPH_H
37#define __YTLIB_PC_GRAPH_H
38
39#include <stdlib.h>
40#include "ytGraph.h"
41#include "util/ytIntArray.h"
42
43typedef struct {
44#ifdef DOXY
45private:
46#endif /* DOXY */
47 ytGraph super;
48 int nodes;
49 ytIntArray * parents;
50 ytIntArray * children;
51} ytPCGraph;
52
53ytPCGraph * ytPCGraph_new(int nodes);
54ytObject * ytPCGraph_newI();
55void ytPCGraph_setOrder(ytPCGraph * this, int nodes);
57void ytPCGraph_delete(ytPCGraph * this);
60void ytPCGraph_clear(ytPCGraph * this);
61int ytPCGraph_numNodes(const ytPCGraph * this);
62int ytPCGraph_numParents(const ytPCGraph * this, int j);
63int ytPCGraph_numChildren(const ytPCGraph * this, int j);
64int ytPCGraph_numEdges(const ytPCGraph * this);
65int ytPCGraph_degree(const ytPCGraph * this, int j);
66int ytPCGraph_getParent(const ytPCGraph * this, int j, int k);
67int ytPCGraph_getChild(const ytPCGraph * this, int j, int k);
68const int * ytPCGraph_getParents(const ytPCGraph * this, int j);
69const int * ytPCGraph_getChildren(const ytPCGraph * this, int j);
70int ytPCGraph_checkEdge(const ytPCGraph * this, int src, int dst);
71void ytPCGraph_addEdge(ytPCGraph * this, int src, int dst);
72void ytPCGraph_removeEdge(ytPCGraph * this, int src, int dst);
73int ytPCGraph_removeLastEdge(ytPCGraph * this, int src, int dst);
74void ytPCGraph_copy(ytPCGraph * this, const ytPCGraph * src);
75void ytPCGraph_copyGraph(ytPCGraph * this, const ytGraph * src);
76void ytPCGraph_addGraph(ytPCGraph * this, const ytGraph * src);
77ytGraphEdgeIter * ytPCGraph_edgeIter(const ytPCGraph * this);
78void ytPCGraph_edgeIterNext(const ytPCGraph * this, ytGraphEdgeIter * iter);
79void ytPCGraph_print(const ytPCGraph * this, FILE * fp);
80int ytPCGraph_test(int argc, char * argv[]);
81
82#endif /* __YTLIB_PC_GRAPH_H */
Interface class for handling graph structure.
Expandable array.
The basis class.
Definition: ytGraph.h:53
Definition: ytPCGraph.h:43
int ytPCGraph_numChildren(const ytPCGraph *this, int j)
Returns the number of children of the specified node.
Definition: ytPCGraph.c:249
void ytPCGraph_addEdge(ytPCGraph *this, int src, int dst)
Adds an edge to the graph.
Definition: ytPCGraph.c:352
const int * ytPCGraph_getChildren(const ytPCGraph *this, int j)
Returns the pointer to the children.
Definition: ytPCGraph.c:331
void ytPCGraph_clear(ytPCGraph *this)
Removes all the edges.
Definition: ytPCGraph.c:187
int ytPCGraph_getChild(const ytPCGraph *this, int j, int k)
Returns the child index of the node.
Definition: ytPCGraph.c:304
int ytPCGraph_getParent(const ytPCGraph *this, int j, int k)
Returns the parent index of the node.
Definition: ytPCGraph.c:294
int ytPCGraph_numNodes(const ytPCGraph *this)
Returns the number of nodes in the graph.
Definition: ytPCGraph.c:198
void ytPCGraph_addGraph(ytPCGraph *this, const ytGraph *src)
Adds edges in the given graph into this graph.
Definition: ytPCGraph.c:471
int ytPCGraph_degree(const ytPCGraph *this, int j)
Returns the number of edges connected to the node.
Definition: ytPCGraph.c:278
void ytPCGraph_removeEdge(ytPCGraph *this, int src, int dst)
Removes the edge.
Definition: ytPCGraph.c:367
ytObject * ytPCGraph_obj(ytPCGraph *this)
Returns the pointer to the ytObject of this instance.
Definition: ytPCGraph.c:131
const int * ytPCGraph_getParents(const ytPCGraph *this, int j)
Returns the pointer to the parents.
Definition: ytPCGraph.c:317
void ytPCGraph_copy(ytPCGraph *this, const ytPCGraph *src)
Copies edges to this graph.
Definition: ytPCGraph.c:417
int ytPCGraph_numEdges(const ytPCGraph *this)
Returns the number of edges in the graph.
Definition: ytPCGraph.c:261
int ytPCGraph_checkEdge(const ytPCGraph *this, int src, int dst)
Checks if the specified edge exists in the graph.
Definition: ytPCGraph.c:215
int ytPCGraph_numParents(const ytPCGraph *this, int j)
Returns the number of parents of the specified node.
Definition: ytPCGraph.c:235
ytPCGraph * ytPCGraph_new(int nodes)
Generates the new ytPCGraph instance.
Definition: ytPCGraph.c:93
ytPCGraph * ytPCGraph_from_Graph(ytGraph *this)
Returns the pointer to the ytPCGraph from ytGraph.
Definition: ytPCGraph.c:178
int ytPCGraph_removeLastEdge(ytPCGraph *this, int src, int dst)
Removes the last edge.
Definition: ytPCGraph.c:393
ytGraph * ytPCGraph_Graph(ytPCGraph *this)
Definition: ytPCGraph.c:172
void ytPCGraph_copyGraph(ytPCGraph *this, const ytGraph *src)
Copies edges to this graph.
Definition: ytPCGraph.c:440
void ytPCGraph_delete(ytPCGraph *this)
Deletes the ytPCGraph instance.
Definition: ytPCGraph.c:156