Debian Codegraph @

lib/ortho/sgraph.h

raw
1
2 /*************************************************************************
3 * Copyright (c) 2011 AT&T Intellectual Property
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors: Details at https://graphviz.org
10 *************************************************************************/
11
12 #pragma once
13
14 #include <ortho/structures.h>
15 #include <stdbool.h>
16
17 typedef struct snode snode;
18 typedef struct sedge sedge;
19
20 /** @brief a node of search graph @ref sgraph,
21 * is created as a border segment between two adjusted cells of type @ref cell.
22 *
23 * Nodes and a search graph are created by functions @ref mkMazeGraph, @ref findSVert and @ref createSNode.
24 */
25
26 struct snode {
27 int n_val, n_idx;
28 snode* n_dad;
29 sedge* n_edge;
30 short n_adj;
31 short save_n_adj;
32 struct cell* cells[2]; ///< [0] - left or botom, [1] - top or right adjusted cell
33
34 /** @brief edges incident on this node
35 * -- stored as indices of the edges array in the graph
36 */
37 int* adj_edge_list;
38 int index;
39 bool isVert; /* true if node corresponds to vertical segment */
40 };
41
42 struct sedge {
43 double weight; /* weight of edge */
44 int cnt; /* paths using edge */
45 /* end-points of the edge
46 * -- stored as indices of the nodes vector in the graph
47 */
48 int v1, v2;
49 };
50
51 typedef struct {
52 int nnodes, nedges;
53 int save_nnodes, save_nedges;
54 snode* nodes;
55 sedge* edges;
56 } sgraph;
57
58 extern void reset(sgraph*);
59 extern void gsave(sgraph*);
60 extern sgraph *createSGraph(size_t);
61 extern void freeSGraph (sgraph*);
62 extern void initSEdges(sgraph *g, size_t maxdeg);
63 extern int shortPath (sgraph* g, snode* from, snode* to);
64 extern snode* createSNode (sgraph*);
65 extern sedge* createSEdge (sgraph* g, snode* v0, snode* v1, double wt);