Skip to content

Commit 3a536cd

Browse files
committed
docs: improve docs for base input check functions
1 parent 40e6cd0 commit 3a536cd

File tree

2 files changed

+81
-53
lines changed

2 files changed

+81
-53
lines changed

experimental/utility/LAGraph_CFL_check_base_inputs.c

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,23 @@ typedef struct
1919
rule.count++; \
2020
}
2121

22-
// Checks the input CFL grammar
23-
GrB_Info LAGraph_CFL_check_grammar(int64_t terms_count, int64_t nonterms_count, int64_t rules_count, const LAGraph_rule_WCNF *rules, char *msg)
22+
// LAGraph_CFL_check_grammar_input: Checks the input CFL grammar
23+
//
24+
// Checks:
25+
// - The rule array is not NULL
26+
// - Valid number of terms/non-terms/rules (> 0)
27+
// - Correctly formed grammar rules in WCNF format
28+
//
29+
// If an error occurs: adds a message using ADD_TO_MSG,
30+
// returns the corresponding GrB_Info
31+
32+
GrB_Info LAGraph_CFL_check_grammar_input(
33+
int64_t terms_count, // Number of terminal symbols
34+
int64_t nonterms_count, // Number of non-terminal symbols
35+
int64_t rules_count, // Number of rules in the grammar
36+
const LAGraph_rule_WCNF *rules, // Array of rules
37+
char *msg // Message string for error reporting
38+
)
2439
{
2540
LG_CLEAR_MSG;
2641
size_t msg_len = 0;
@@ -106,8 +121,20 @@ GrB_Info LAGraph_CFL_check_grammar(int64_t terms_count, int64_t nonterms_count,
106121
return GrB_SUCCESS;
107122
}
108123

109-
// Checks the input graph for CFL algorithms
110-
GrB_Info LAGraph_CFL_check_graph(const GrB_Matrix *adj_matrices, int64_t terms_count, char *msg)
124+
// LAGraph_CFL_check_graph_input: Checks the input graph for CFL algorithms
125+
//
126+
// Checks:
127+
// - The adjacency matrix array is not NULL
128+
// - There are no entries equal to NULL in the adjacency matrix array
129+
//
130+
// If an error occurs: adds a message using ADD_TO_MSG,
131+
// returns the corresponding GrB_NULL_POINTER
132+
133+
GrB_Info LAGraph_CFL_check_graph_input(
134+
const GrB_Matrix *adj_matrices, // Adjacency matrix array for terminals
135+
int64_t terms_count, // Number of terminal symbols
136+
char *msg // Message string for error reporting
137+
)
111138
{
112139
LG_CLEAR_MSG;
113140
size_t msg_len = 0;
@@ -142,35 +169,20 @@ GrB_Info LAGraph_CFL_check_graph(const GrB_Matrix *adj_matrices, int64_t terms_c
142169
}
143170

144171
// LAGraph_CFL_check_base_inputs: Checks the input graph and CFL grammar for algorithms working with it
145-
//
146-
// Checks:
147-
// - The adjacency matrix array is not NULL
148-
// - There are no entries equal to NULL in the adjacency matrix array
149-
// - The rule array is not NULL
150-
// - Valid number of terms/non-terms/rules (> 0)
151-
// - Correctly formed grammar rules in WCNF format
152-
//
153-
// Parameters:
154-
// - adj_matrices: adjacency matrix array for terminals
155-
// - terms_count: number of terminal symbols
156-
// - nonterms_count: number of non-terminal symbols
157-
// - rules_count: number of rules in the grammar
158-
// - rules: array of rules
159-
//
160-
// If an error occurs: adds a message using ADD_TO_MSG,
161-
// returns the corresponding GrB_Info
162-
172+
// Equivalent to calling LAGraph_CFL_check_graph_input + LAGraph_CFL_check_grammar_input
173+
// See LAGraph_CFL_check_graph_input and LAGraph_CFL_check_grammar_input for details
163174
GrB_Info LAGraph_CFL_check_base_inputs(
164-
const GrB_Matrix *adj_matrices,
165-
int64_t terms_count,
166-
int64_t nonterms_count,
167-
int64_t rules_count,
168-
const LAGraph_rule_WCNF *rules,
169-
char *msg)
175+
const GrB_Matrix *adj_matrices, // Adjacency matrix array for terminals
176+
int64_t terms_count, // Number of terminal symbols
177+
int64_t nonterms_count, // Number of non-terminal symbols
178+
int64_t rules_count, // Number of rules in the grammar
179+
const LAGraph_rule_WCNF *rules, // Array of rules
180+
char *msg // Message string for error reporting
181+
)
170182
{
171183
LG_CLEAR_MSG;
172184
size_t msg_len = 0;
173-
LG_TRY(LAGraph_CFL_check_graph(adj_matrices, terms_count, msg));
174-
LG_TRY(LAGraph_CFL_check_grammar(terms_count, nonterms_count, rules_count, rules, msg));
185+
LG_TRY(LAGraph_CFL_check_graph_input(adj_matrices, terms_count, msg));
186+
LG_TRY(LAGraph_CFL_check_grammar_input(terms_count, nonterms_count, rules_count, rules, msg));
175187
return GrB_SUCCESS;
176188
}

include/LAGraphX.h

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,32 +1380,49 @@ void LAGraph_CFL_classify_rules(
13801380
} \
13811381
}
13821382

1383-
// LAGraph_CFL_check_base_inputs: Checks the input graph and CFL grammar for algorithms working with it
1383+
// LAGraph_CFL_check_grammar_input: Checks the input CFL grammar
13841384
//
13851385
// Checks:
1386-
// - The adjacency matrix array is not NULL
1387-
// - There are no entries equal to NULL in the adjacency matrix array
13881386
// - The rule array is not NULL
13891387
// - Valid number of terms/non-terms/rules (> 0)
13901388
// - Correctly formed grammar rules in WCNF format
13911389
//
1392-
// Parameters:
1393-
// - adj_matrices: adjacency matrix array for terminals
1394-
// - terms_count: number of terminal symbols
1395-
// - nonterms_count: number of non-terminal symbols
1396-
// - rules_count: number of rules in the grammar
1397-
// - rules: array of rules
1398-
//
13991390
// If an error occurs: adds a message using ADD_TO_MSG,
14001391
// returns the corresponding GrB_Info
14011392

1393+
GrB_Info LAGraph_CFL_check_grammar_input(
1394+
int64_t terms_count, // Number of terminal symbols
1395+
int64_t nonterms_count, // Number of non-terminal symbols
1396+
int64_t rules_count, // Number of rules in the grammar
1397+
const LAGraph_rule_WCNF *rules, // Array of rules
1398+
char *msg // Message string for error reporting
1399+
);
1400+
1401+
// LAGraph_CFL_check_graph_input: Checks the input graph for CFL algorithms
1402+
//
1403+
// Checks:
1404+
// - The adjacency matrix array is not NULL
1405+
// - There are no entries equal to NULL in the adjacency matrix array
1406+
//
1407+
// If an error occurs: adds a message using ADD_TO_MSG,
1408+
// returns the corresponding GrB_NULL_POINTER
1409+
1410+
GrB_Info LAGraph_CFL_check_graph_input(
1411+
const GrB_Matrix *adj_matrices, // Adjacency matrix array for terminals
1412+
int64_t terms_count, // Number of terminal symbols
1413+
char *msg // Message string for error reporting
1414+
);
1415+
1416+
// LAGraph_CFL_check_base_inputs: Checks the input graph and CFL grammar for algorithms working with it
1417+
// Equivalent to calling LAGraph_CFL_check_graph_input + LAGraph_CFL_check_grammar_input
1418+
// See LAGraph_CFL_check_graph_input and LAGraph_CFL_check_grammar_input for details
14021419
GrB_Info LAGraph_CFL_check_base_inputs(
1403-
const GrB_Matrix *adj_matrices,
1404-
int64_t terms_count,
1405-
int64_t nonterms_count,
1406-
int64_t rules_count,
1407-
const LAGraph_rule_WCNF *rules,
1408-
char *msg
1420+
const GrB_Matrix *adj_matrices, // Adjacency matrix array for terminals
1421+
int64_t terms_count, // Number of terminal symbols
1422+
int64_t nonterms_count, // Number of non-terminal symbols
1423+
int64_t rules_count, // Number of rules in the grammar
1424+
const LAGraph_rule_WCNF *rules, // Array of rules
1425+
char *msg // Message string for error reporting
14091426
);
14101427

14111428
//------------------------------------------------------------------------------
@@ -1414,13 +1431,12 @@ GrB_Info LAGraph_CFL_check_base_inputs(
14141431

14151432
LAGRAPHX_PUBLIC
14161433
int LAGraph_HelloWorld // a simple algorithm, just for illustration
1417-
(
1418-
// output
1419-
GrB_Matrix *Yhandle, // Y, created on output
1420-
// input: not modified
1421-
LAGraph_Graph G,
1422-
char *msg
1423-
) ;
1434+
(
1435+
// output
1436+
GrB_Matrix *Yhandle, // Y, created on output
1437+
// input: not modified
1438+
LAGraph_Graph G,
1439+
char *msg);
14241440

14251441
//------------------------------------------------------------------------------
14261442
// run a breadth first search for multiple source nodes

0 commit comments

Comments
 (0)