46#define WORD_CLUSTER_LENGTH 3
47#define BUFFER_LENGTH 256
59 struct Words *
this = malloc(
sizeof(
struct Words));
89 unsigned int typeVertex = 0;
98 for (
unsigned int offset = length; offset > 0; offset--) {
100 unsigned int index = offset - 1;
115 if (0 == wordClusterStart) {
144 bottoms[index] = wordCluster[1];
150 typeVertex = wordCluster[2];
156 for (
unsigned int last = length - 1; last > 0; last--) {
158 for (
unsigned int current = 1; current <= last; current++) {
160 unsigned int previous = current - 1;
196 unsigned int common = 0;
198 for (
unsigned int targetIndex = 0; targetIndex < targetCount; targetIndex++) {
199 for (
unsigned int sourceIndex = 0; sourceIndex < sourceCount; sourceIndex++) {
200 if (targets[targetIndex] == sources[sourceIndex]) {
201 common = targets[targetIndex];
243 bottoms[previous] = wordCluster[1];
244 typeVertex = wordCluster[2];
251void Words_readWord(
struct Words *
this,
unsigned int word,
unsigned int length,
unsigned int *characters,
int *error)
270 tops[0] = wordCluster[1];
272 unsigned int last = 0;
273 int atBinaryBorder = 0;
275 while (! atBinaryBorder) {
277 unsigned int index = last;
287 if (0 == lastTarget) {
298 tops[index + 1] = wordCluster[2];
314 tops[index] = wordCluster[2];
324 if (! atBinaryBorder) {
328 if (last == length) {
337 for (
unsigned int index = 0; index <= last; index++) {
351 characters[index] = code;
unsigned int Binary_writeCode(struct Binary *this, unsigned int input, int *error)
It writes binary value from an unsigned integer into a graph.
struct Binary * Binary_destruct(struct Binary *this)
unsigned int Binary_readCode(struct Binary *this, unsigned int code, int *error)
It reads binary value into an unsigned integer when given a vertex from a binary cluster.
void Graph_readSources(const struct Graph *this, unsigned int target, unsigned int length, unsigned int *sources, int *error)
It reads all source vertices that have an edge leading to a particular target vertex.
unsigned int Graph_countTargets(const struct Graph *this, unsigned int source, int *error)
It counts all target vertices that have an edge leading from a particular source vertex.
unsigned int Graph_countSources(const struct Graph *this, unsigned int target, int *error)
It counts all source vertices that have an edge leading to a particular target vertex.
void Graph_addEdge(struct Graph *this, unsigned int source, unsigned int target, int *error)
It adds a directed edge from a source vertex to a target vertex.
unsigned int Graph_readLastTarget(const struct Graph *this, unsigned int source, int *error)
It reads the last target vertex of a source vertex, if it exists.
unsigned int Graph_readLastSource(const struct Graph *this, unsigned int target, int *error)
It reads the last source vertex of a target vertex, if it exists.
void Graph_readCluster(const struct Graph *this, unsigned int predecessor, unsigned int length, unsigned int *vertices, int *error)
void Graph_readTargets(const struct Graph *this, unsigned int source, unsigned int length, unsigned int *targets, int *error)
It reads all target vertices that have an edge leading from a particular source vertex.
void Graph_addCluster(struct Graph *this, unsigned int length, unsigned int *vertices, int *error)
struct Utf8 * Utf8_destruct(struct Utf8 *this)
struct Words * Words_destruct(struct Words *this)
It destructs a managing object for all words in a graph.
struct Words * Words_construct(unsigned int wordType, struct Binary *binary, struct Utf8 *utf8, struct Graph *graph, int *error)
It constructs a new managing object for all words in a graph.
#define WORD_CLUSTER_LENGTH
void Words_readWord(struct Words *this, unsigned int word, unsigned int length, unsigned int *characters, int *error)
It reads a word from a graph.
unsigned int Words_writeWord(struct Words *this, unsigned int length, unsigned int *characters, int *error)
It writes one word into a graph.
#define ERROR_WORD_TOO_LONG
#define ERROR_WORD_BUFFER_TOO_SMALL
#define ERROR_WORD_TOO_RICH
A managing object for all words in a graph.
struct Utf8 * utf8
its UTF8 converter
unsigned int wordType
its vertex that all word clusters will be connected to
struct Graph * graph
its graph storage with needed managing objects installed
struct Binary * binary
its manging object for binary character codes