24 #include <sys/types.h>
44 #define BIDIRECTIONAL 1
60 dglInt32_t xyz_from[3], xyz_to[3], direction[2];
65 xyz_from[0] = from %
NCOLS;
66 xyz_from[1] = from /
NCOLS;
69 xyz_to[0] = to %
NCOLS;
70 xyz_to[1] = to /
NCOLS;
80 dglAddEdgeX(pgraph, from, to, cost, arc, xyz_from, xyz_to,
83 fprintf(stderr,
"dglAddEdge error: %s\n",
dglStrerror(pgraph));
88 if ((arc % 1024) == 0 || fLast) {
90 printf(
"add arc %07ld - from %07ld - to %07ld - cost %07ld\r",
94 (
"add arc %07ld - from %07ld - to %07ld - cost %07ld . Clock: tot %09ld nt %09ld o %09ld\r",
95 arc, from, to, cost, pgraph->clkAddEdge / pgraph->cAddEdge,
96 pgraph->clkNodeTree / pgraph->cAddEdge,
97 (pgraph->clkAddEdge - pgraph->clkNodeTree) / pgraph->cAddEdge);
104 int main(
int argc,
char **argv)
110 int irow, icol, itrow, itcol;
111 int irowsave, icolsave;
122 FACTOR, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
134 "Avoid node ids sorting at insertion - default False")
136 "Output Graph Version {1,2,3} - default 1")
142 if (pszFileout ==
NULL) {
150 version = atoi(pszVersion);
155 printf(
"graph initialize...");
158 version,
sizeof(xyz),
173 printf(
"add horizontal and vertical edges...\n");
174 for (irow = 0; irow <
NROWS; irow++) {
176 if (fInterlaced ==
True) {
182 for (icol = 0; icol <
NCOLS; icol++) {
184 if (fInterlaced ==
True) {
194 from = irow * NCOLS + icol;
195 to = irow * NCOLS + itcol;
198 if (_add_edge(&graph, from, to, cost, arc,
'r', 0)) {
203 if (_add_edge(&graph, to, from, cost, arc,
'l', 0)) {
210 from = irow * NCOLS + icol;
211 to = itrow * NCOLS + icol;
214 if (_add_edge(&graph, from, to, cost, arc,
'b', 0)) {
219 if (_add_edge(&graph, to, from, cost, arc,
't', 0)) {
225 if (fInterlaced ==
True)
229 if (fInterlaced ==
True)
232 _add_edge(&graph, to, from, cost, arc,
'x', 1);
236 printf(
"\nadd oblique edges...\n");
237 for (irow = 0; irow <
NROWS; irow++) {
238 for (icol = 0; icol <
NCOLS; icol++) {
242 if (itrow < NROWS && itcol < NCOLS) {
243 from = irow * NCOLS + icol;
244 to = itrow * NCOLS + itcol;
247 if (_add_edge(&graph, from, to, cost, arc,
'o', 0)) {
252 if (_add_edge(&graph, to, from, cost, arc,
'O', 0)) {
259 _add_edge(&graph, to, from, cost, arc,
'x', 1);
273 fprintf(stderr,
"\ndglEdge_T_Initialize error: %s\n",
278 printf(
"edge: id=%ld cost=%ld\n",
287 printf(
"graph flattening...");
291 fprintf(stderr,
"\ndglFlatten error: %s\n",
dglStrerror(&graph));
297 printf(
"graph write...");
299 if ((fd = open(pszFileout, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) {
305 fprintf(stderr,
"\ndglWrite error: %s\n",
dglStrerror(&graph));
312 printf(
"graph release...");
315 printf(
"program finished.\n");